summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-07-10 14:20:11 +0000
committerjilles <jilles@FreeBSD.org>2011-07-10 14:20:11 +0000
commit3396d1eaffa995e1291d40431f4bbed3fc31df0d (patch)
treed191f37dde3c920c0593f86a64ae8000f3d83c89 /lib
parent49fd1cbb236fff2345c8fa5e255cc59c3db51714 (diff)
downloadFreeBSD-src-3396d1eaffa995e1291d40431f4bbed3fc31df0d.zip
FreeBSD-src-3396d1eaffa995e1291d40431f4bbed3fc31df0d.tar.gz
posix_spawn: If an error is detected in the child process, reap the zombie.
Formerly, in this case an error was returned but the pid was also returned to the application, requiring the application to use unspecified behaviour (the returned pid in error situations) to avoid zombies. Now, reap the zombie and do not return the pid. MFC after: 2 weeks
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/posix_spawn.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c
index e4ceb20..e3124b2 100644
--- a/lib/libc/gen/posix_spawn.c
+++ b/lib/libc/gen/posix_spawn.c
@@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/queue.h>
+#include <sys/wait.h>
#include <errno.h>
#include <fcntl.h>
@@ -216,7 +217,9 @@ do_posix_spawn(pid_t *pid, const char *path,
error = errno;
_exit(127);
default:
- if (pid != NULL)
+ if (error != 0)
+ _waitpid(p, NULL, WNOHANG);
+ else if (pid != NULL)
*pid = p;
return (error);
}
OpenPOWER on IntegriCloud