]> Zhao Yanbai Git Server - minix.git/commitdiff
libc: make posix_spawn(3) clean up child on failure 81/3381/1
authorDavid van Moolenbroek <david@minix3.org>
Tue, 20 Dec 2016 14:46:42 +0000 (14:46 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Wed, 28 Dec 2016 13:05:55 +0000 (13:05 +0000)
Change-Id: I39a321f23326485fca789e5792a57532d1036716

minix/lib/libc/sys/posix_spawn.c

index 0141fcafed87bcaea4ff006dd136058fc8912090..467fd5989afd2d992ce0e440696d2458d5602279 100644 (file)
@@ -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;