Show More
@@ -8,6 +8,7 b'' | |||
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include <assert.h> |
|
11 | #include <dirent.h> | |
|
11 | 12 | #include <errno.h> |
|
12 | 13 | #include <fcntl.h> |
|
13 | 14 | #include <signal.h> |
@@ -269,6 +270,31 b' static void execcmdserver(const struct c' | |||
|
269 | 270 | } |
|
270 | 271 | } |
|
271 | 272 | |
|
273 | /* close any open files to avoid hanging locks */ | |
|
274 | DIR *dp = opendir("/proc/self/fd"); | |
|
275 | if (dp != NULL) { | |
|
276 | debugmsg("closing files based on /proc contents"); | |
|
277 | struct dirent *de; | |
|
278 | while ((de = readdir(dp))) { | |
|
279 | char *end; | |
|
280 | long fd_value = strtol(de->d_name, &end, 10); | |
|
281 | if (end == de->d_name) { | |
|
282 | /* unable to convert to int (. or ..) */ | |
|
283 | continue; | |
|
284 | } | |
|
285 | if (errno == ERANGE) { | |
|
286 | debugmsg("tried to parse %s, but range error occurred", de->d_name); | |
|
287 | continue; | |
|
288 | } | |
|
289 | if (fd_value > STDERR_FILENO) { | |
|
290 | int res = close(fd_value); | |
|
291 | if (res) { | |
|
292 | debugmsg("tried to close fd %ld: %d (errno: %d)", fd_value, res, errno); | |
|
293 | } | |
|
294 | } | |
|
295 | } | |
|
296 | } | |
|
297 | ||
|
272 | 298 | if (putenv("CHGINTERNALMARK=") != 0) |
|
273 | 299 | abortmsgerrno("failed to putenv"); |
|
274 | 300 | if (execvp(hgcmd, (char **)argv) < 0) |
General Comments 0
You need to be logged in to leave comments.
Login now