diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2016-10-19 00:22:07 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2016-10-19 00:22:07 +0000 |
commit | 08997ab1211eb3ee52feeb7bd9062da2f168f834 (patch) | |
tree | 549afea5f6b44f2acd726913e8e07b4dc49366a8 | |
parent | 8be9590f78d0f7cf04ade6a2ff0bddd365e3fd7c (diff) | |
download | skalibs-08997ab1211eb3ee52feeb7bd9062da2f168f834.tar.xz |
bugfix: child_spawn() error path now closes the right amount of fds
-rw-r--r-- | src/libstddjb/child_spawn.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c index addc7cd..2170a6e 100644 --- a/src/libstddjb/child_spawn.c +++ b/src/libstddjb/child_spawn.c @@ -53,7 +53,7 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const unsigned int i = 0 ; char modifs[m + 1 + n * UINT_FMT] ; byte_copy(modifs, sizeof(NOFDVAR), NOFDVAR "=") ; - for (; i < n ; i++) if (pipe(p[i]) < 0) { e = errno ; goto errp ; } + for (; i < n ; i++) if (pipe(p[i]) < 0) { e = errno ; goto errpi ; } for (i = 0 ; i < n ; i++) if ((ndelay_on(p[i][i & 1]) < 0) || (coe(p[i][i & 1]) < 0)) { @@ -184,6 +184,7 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const #endif errp: i = n ; + errpi: while (i--) { fd_close(p[i][1]) ; |