From 85cc92f23306d688ed9b97d0f7892410c842c447 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Mon, 18 Sep 2017 12:12:58 +0100 Subject: [PATCH] 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. --- uip/rcvdist.c | 4 ++-- uip/whatnowsbr.c | 4 ++-- uip/whom.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) 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 "); -- 2.56.0