]> diplodocus.org Git - nmh/commitdiff
If fork(2) fails then die; don't fall through to execve(2).
authorRalph Corderoy <ralph@inputplus.co.uk>
Mon, 18 Sep 2017 11:12:58 +0000 (12:12 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Mon, 18 Sep 2017 12:10:13 +0000 (13:10 +0100)
It's already been agreed that failure to fork() is so rare these days
that multiple attempts aren't required.  Nor should the code persevere
by calling execve() as if the fork had succeeded, else why bother to
fork?  Instead, die.

uip/rcvdist.c
uip/whatnowsbr.c
uip/whom.c

index a75e21a..f30a573 100644 (file)
@@ -127,8 +127,8 @@ main (int argc, char **argv)
     child_id = fork();
     switch (child_id) {
        case NOTOK: 
-           inform("unable to fork, continuing...");
-           /* FALLTHRU */
+            adios("fork", "failed:");
+
        case OK: 
            execvp (program, vec);
            fprintf (stderr, "unable to exec ");
index c03ceb8..c27ee63 100644 (file)
@@ -821,8 +821,8 @@ sendfile (char **arg, char *file, int pushsw)
     child_id = fork();
     switch (child_id) {
        case NOTOK:
-           inform("unable to fork, so sending directly...");
-           /* FALLTHRU */
+            adios("fork", "failed:");
+
        case OK:
            vec = argsplit(sendproc, &program, &vecp);
            if (pushsw)
index 7a2cacb..c16d2a1 100644 (file)
@@ -184,8 +184,8 @@ main (int argc, char **argv)
 
     switch (distsw ? child_id : OK) {
        case NOTOK:
-           inform("unable to fork, so checking directly...");
-           /* FALLTHRU */
+            adios("fork", "failed:");
+
        case OK:
            execvp (postproc, vec);
            fprintf (stderr, "unable to exec ");