sendmail: fix wrong vfork usage here too
authorDenis Vlasenko <vda.linux@googlemail.com>
Tue, 1 Jul 2008 16:09:07 +0000 (16:09 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Tue, 1 Jul 2008 16:09:07 +0000 (16:09 -0000)
*: shorten error texts

function                                             old     new   delta
launch_helper                                          -     151    +151
vfork_or_die                                          20       -     -20
sendgetmail_main                                    1946    1848     -98
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 151/-118)           Total: 33 bytes

archival/libunarchive/open_transformer.c
archival/tar.c
miscutils/time.c
networking/nc.c
networking/sendmail.c
shell/ash.c

index a6bc623215182320a82153f3f6cb5d4f798a3b2c..a5ee97167354f36bf2ec6e91e47c0f93a0ed78c7 100644 (file)
@@ -23,11 +23,11 @@ int FAST_FUNC open_transformer(int src_fd,
 #if BB_MMU
        pid = fork();
        if (pid == -1)
-               bb_perror_msg_and_die("can't fork");
+               bb_perror_msg_and_die("vfork" + 1);
 #else
        pid = vfork();
        if (pid == -1)
-               bb_perror_msg_and_die("can't vfork");
+               bb_perror_msg_and_die("vfork");
 #endif
 
        if (pid == 0) {
index 526edb69d59eed7cb80b8cd9094fb99e67f3d3f1..bb8920ab274fd06f822b351b5c6f9e3b799a8ff9 100644 (file)
@@ -538,7 +538,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
 
        gzipPid = vfork();
        if (gzipPid < 0)
-               bb_perror_msg_and_die("can't vfork");
+               bb_perror_msg_and_die("vfork");
 
        if (gzipPid == 0) {
                /* child */
index a6d158c53dc25e14397616a802b46c058a12c6fd..cce7d5b3ebe2704df21b0285520cb42021f45216 100644 (file)
@@ -374,7 +374,7 @@ static void run_command(char *const *cmd, resource_t *resp)
        resp->elapsed_ms = monotonic_us() / 1000;
        pid = vfork();          /* Run CMD as child process.  */
        if (pid < 0)
-               bb_error_msg_and_die("cannot fork");
+               bb_perror_msg_and_die("fork");
        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.  */
index 27c58a8c817706b9154c02bb36140f516b4a89b2..2fd42d5f638c0d88fb899bd33f7483d59a23b5bc 100644 (file)
@@ -150,12 +150,9 @@ int nc_main(int argc, char **argv)
                        goto accept_again;
                }
                /* child (or main thread if no multiple -l) */
-               if (cfd) {
-                       dup2(cfd, 0);
-                       close(cfd);
-               }
-               dup2(0, 1);
-               dup2(0, 2);
+               xmove_fd(cfd, 0);
+               xdup2(0, 1);
+               xdup2(0, 2);
                USE_NC_EXTRA(BB_EXECVP(execparam[0], execparam);)
                /* Don't print stuff or it will go over the wire.... */
                _exit(127);
index 1c23ca290f758c9733136a2317443e6365f7a1ee..b58055d396875194ee5dbf7eadefb2aaee65aad8 100644 (file)
@@ -120,15 +120,6 @@ static void signal_handler(int signo)
 #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
@@ -137,7 +128,9 @@ static void launch_helper(const char **argv)
 
        xpipe(pipes);
        xpipe(pipes+2);
-       helper_pid = vfork_or_die();
+       helper_pid = vfork();
+       if (helper_pid < 0)
+               bb_perror_msg_and_die("vfork");
        idx = (!helper_pid) * 2;
        xdup2(pipes[idx], STDIN_FILENO);
        xdup2(pipes[3-idx], STDOUT_FILENO);
index 85064d5af2917a2423c2feb6d42bf28619340c2b..58bfc5278a0a5d4bc1aa0aef33a6c29bf09aad1f 100644 (file)
@@ -4581,7 +4581,7 @@ forkshell(struct job *jp, union node *n, int mode)
                TRACE(("Fork failed, errno=%d", errno));
                if (jp)
                        freejob(jp);
-               ash_msg_and_raise_error("cannot fork");
+               ash_msg_and_raise_error("can't fork");
        }
        if (pid == 0)
                forkchild(jp, /*n,*/ mode);