X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fpipecmd%2Fpipecmd.c;h=afeaf5a0a256de9839b39b522f0cc1e3e8f142a9;hp=d45713b6f8015db478592f5795fdfda474605c3c;hb=46cfc3ad7e2defa96ba04366b60436dfa078ef87;hpb=b98c68473e3317e09ebcc2d7d46e374fc08c531d diff --git a/ccan/pipecmd/pipecmd.c b/ccan/pipecmd/pipecmd.c index d45713b6..afeaf5a0 100644 --- a/ccan/pipecmd/pipecmd.c +++ b/ccan/pipecmd/pipecmd.c @@ -137,6 +137,13 @@ pid_t pipecmdarr(int *fd_tochild, int *fd_fromchild, int *fd_errfromchild, goto child_errno_fail; close(errfromchild[1]); } + + /* Make (fairly!) sure all other fds are closed. */ + int max = sysconf(_SC_OPEN_MAX); + for (int i = 3; i < max; i++) + if (i != execfail[1]) + close(i); + execvp(arr[0], arr); child_errno_fail: