From: Ralph Corderoy Date: Mon, 18 Sep 2017 11:12:58 +0000 (+0100) Subject: If fork(2) fails then die; don't fall through to execve(2). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/85cc92f23306d688ed9b97d0f7892410c842c447?ds=inline If fork(2) fails then die; don't fall through to execve(2). 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. --- diff --git a/uip/rcvdist.c b/uip/rcvdist.c index a75e21ac..f30a573c 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -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 "); diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index c03ceb82..c27ee63d 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -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) diff --git a/uip/whom.c b/uip/whom.c index 7a2cacb8..c16d2a14 100644 --- a/uip/whom.c +++ b/uip/whom.c @@ -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 ");