*: introduce and use xvfork()
function old new delta time_main 1052 1285 +233 crontab_main 623 856 +233 ifupdown_main 2202 2403 +201 xvfork - 20 +20 passwd_main 1049 1053 +4 grave 1068 1066 -2 script_main 935 921 -14 vfork_or_die 20 - -20 vfork_compressor 206 175 -31 open_as_user 109 - -109 popen2 218 - -218 edit_file 910 690 -220 run_command 268 - -268 ------------------------------------------------------------------------------ (add/remove: 1/4 grow/shrink: 4/4 up/down: 691/-882) Total: -191 bytes
This commit is contained in:
@@ -38,10 +38,8 @@ static void change_user(const struct passwd *pas)
|
||||
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;
|
||||
@@ -65,9 +63,7 @@ static int open_as_user(const struct passwd *pas, const char *file)
|
||||
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 */
|
||||
|
@@ -372,9 +372,7 @@ static void run_command(char *const *cmd, resource_t *resp)
|
||||
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. */
|
||||
|
Reference in New Issue
Block a user