if (pid == -1)
bb_perror_msg_and_die("can't fork");
#else
- pid = vfork();
- if (pid == -1)
- bb_perror_msg_and_die("can't vfork");
+ pid = xvfork();
#endif
if (pid == 0) {
(void) &zip_exec;
#endif
- gzipPid = vfork();
- if (gzipPid < 0)
- bb_perror_msg_and_die("can't vfork");
+ gzipPid = xvfork();
if (gzipPid == 0) {
/* child */
/* DAEMON_DEVNULL_STDIO is superfluous -
* it's always done by bb_daemonize() */
#else
- pid_t pid = vfork();
- if (pid < 0) /* error */
- bb_perror_msg_and_die("vfork");
+ pid_t pid = xvfork();
if (pid != 0) {
/* parent */
/* why _exit? the child may have changed the stack,
#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__)
#endif
+pid_t xvfork(void) FAST_FUNC;
+
/* NOMMU friendy fork+exec */
pid_t spawn(char **argv) FAST_FUNC;
pid_t xspawn(char **argv) FAST_FUNC;
lib-y += xgetcwd.o
lib-y += xgethostbyname.o
lib-y += xreadlink.o
+lib-y += xvfork.o
# conditionally compiled objects:
lib-$(CONFIG_FEATURE_MOUNT_LOOP) += loop.o
if (re_execed)
return;
- pid = vfork();
- if (pid < 0) /* wtf? */
- bb_perror_msg_and_die("vfork");
+ pid = xvfork();
if (pid) /* parent */
exit(EXIT_SUCCESS);
/* child - re-exec ourself */
static void edit_file(const struct passwd *pas, const char *file)
{
const char *ptr;
- int pid = vfork();
+ int pid = xvfork();
- if (pid < 0) /* failure */
- bb_perror_msg_and_die("vfork");
if (pid) { /* parent */
wait4pid(pid);
return;
pid_t pid;
char c;
- pid = vfork();
- if (pid < 0) /* ERROR */
- bb_perror_msg_and_die("vfork");
+ pid = xvfork();
if (pid) { /* PARENT */
if (wait4pid(pid) == 0) {
/* exitcode 0: child says it can read */
void (*quit_signal)(int);
resp->elapsed_ms = monotonic_us() / 1000;
- pid = vfork(); /* Run CMD as child process. */
- if (pid < 0)
- bb_error_msg_and_die("cannot fork");
+ pid = xvfork(); /* Run CMD as child process. */
if (pid == 0) { /* If child. */
/* Don't cast execvp arguments; that causes errors on some systems,
versus merely warnings if the cast is left off. */
xpiped_pair(outfd);
fflush(NULL);
- pid = vfork();
+ pid = xvfork();
- switch (pid) {
- case -1: /* failure */
- bb_perror_msg_and_die("vfork");
- case 0: /* child */
+ if (pid == 0) { /* child */
/* NB: close _first_, then move fds! */
close(infd.wr);
close(outfd.rd);
#undef err
}
-/* libbb candidate */
-static pid_t vfork_or_die(void)
-{
- pid_t pid = vfork();
- if (pid < 0)
- bb_perror_msg_and_die("vfork");
- return pid;
-}
-
static void launch_helper(const char **argv)
{
// setup vanilla unidirectional pipes interchange
xpipe(pipes);
xpipe(pipes+2);
- helper_pid = vfork_or_die();
+ helper_pid = xvfork();
idx = (!helper_pid) * 2;
xdup2(pipes[idx], STDIN_FILENO);
xdup2(pipes[3-idx], STDOUT_FILENO);
* huge=`cat TESTFILE` # will block here forever
* echo OK
*/
- pid = BB_MMU ? fork() : vfork();
+ pid = BB_MMU ? fork() : xvfork();
+#if BB_MMU
if (pid < 0)
- bb_perror_msg_and_die(BB_MMU ? "fork" : "vfork");
+ bb_perror_msg_and_die("fork");
+#endif
if (pid == 0) { /* child */
if (ENABLE_HUSH_JOB)
die_sleep = 0; /* let nofork's xfuncs die */
/* TODO: SIGWINCH? pass window size changes down to slave? */
- child_pid = vfork();
- if (child_pid < 0) {
- bb_perror_msg_and_die("vfork");
- }
+ child_pid = xvfork();
if (child_pid) {
/* parent */