Show More
@@ -418,11 +418,7 b' hgclient_t *hgc_open(const char *socknam' | |||
|
418 | 418 | |
|
419 | 419 | /* don't keep fd on fork(), so that it can be closed when the parent |
|
420 | 420 | * process get terminated. */ |
|
421 | int flags = fcntl(fd, F_GETFD); | |
|
422 | if (flags < 0) | |
|
423 | abortmsgerrno("cannot get flags of socket"); | |
|
424 | if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) | |
|
425 | abortmsgerrno("cannot set flags of socket"); | |
|
421 | fsetcloexec(fd); | |
|
426 | 422 | |
|
427 | 423 | struct sockaddr_un addr; |
|
428 | 424 | addr.sun_family = AF_UNIX; |
@@ -8,6 +8,7 b'' | |||
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include <errno.h> |
|
11 | #include <fcntl.h> | |
|
11 | 12 | #include <signal.h> |
|
12 | 13 | #include <stdarg.h> |
|
13 | 14 | #include <stdio.h> |
@@ -91,6 +92,15 b' void fchdirx(int dirfd)' | |||
|
91 | 92 | abortmsgerrno("failed to fchdir"); |
|
92 | 93 | } |
|
93 | 94 | |
|
95 | void fsetcloexec(int fd) | |
|
96 | { | |
|
97 | int flags = fcntl(fd, F_GETFD); | |
|
98 | if (flags < 0) | |
|
99 | abortmsgerrno("cannot get flags of fd %d", fd); | |
|
100 | if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) | |
|
101 | abortmsgerrno("cannot set flags of fd %d", fd); | |
|
102 | } | |
|
103 | ||
|
94 | 104 | void *mallocx(size_t size) |
|
95 | 105 | { |
|
96 | 106 | void *result = malloc(size); |
General Comments 0
You need to be logged in to leave comments.
Login now