From 1bb466dd36c0591122401dfd685782ec28865fc3 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Tue, 20 Dec 2016 14:46:42 +0000 Subject: [PATCH] libc: make posix_spawn(3) clean up child on failure Change-Id: I39a321f23326485fca789e5792a57532d1036716 --- minix/lib/libc/sys/posix_spawn.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/minix/lib/libc/sys/posix_spawn.c b/minix/lib/libc/sys/posix_spawn.c index 0141fcafe..467fd5989 100644 --- a/minix/lib/libc/sys/posix_spawn.c +++ b/minix/lib/libc/sys/posix_spawn.c @@ -265,6 +265,9 @@ posix_spawn(pid_t * __restrict pid, const char * __restrict path, error = errno; close(pfd[0]); + if (error != 0) + (void)waitpid(p, NULL, 0); + if (pid != NULL) *pid = p; return error; -- 2.44.0