summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/posix_spawn.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen/posix_spawn.c')
-rw-r--r--lib/libc/gen/posix_spawn.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c
index 58044b3..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>
@@ -182,7 +183,7 @@ process_file_actions(const posix_spawn_file_actions_t fa)
if (error)
return (error);
}
- return (0);
+ return (0);
}
static int
@@ -193,7 +194,7 @@ do_posix_spawn(pid_t *pid, const char *path,
{
pid_t p;
volatile int error = 0;
-
+
p = vfork();
switch (p) {
case -1:
@@ -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