blob: c8f9d277ea8d8142b2b628f93b4fc14235fdb67b [file] [log] [blame]
Eric Andersen35e643b2003-07-28 07:40:39 +00001/*
2 * Rexec program for system have fork() as vfork() with foregound option
3 * Copyright (C) Vladminr Oleynik and many different people.
4 */
5
6#include <unistd.h>
7#include "libbb.h"
8
9
10#if defined(__uClinux__)
11void vfork_daemon_rexec(int argc, char **argv, char *foreground_opt)
12{
13 char **vfork_args;
14 int a = 0;
15
16 vfork_args = xcalloc(sizeof(char *), argc + 3);
17 while(*argv) {
18 vfork_args[a++] = *argv;
19 argv++;
20 }
21 vfork_args[a] = foreground_opt;
22 execvp("/proc/self/exe", vfork_args);
23 vfork_args[0] = "/bin/busybox";
24 execv(vfork_args[0], vfork_args);
25 bb_perror_msg_and_die("execv %s", vfork_args[0]);
26}
27#endif /* uClinux */