From ece26516401c2e621e50d293db410628c4f6b0fe Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Sun, 27 Aug 2023 09:56:46 -0700 Subject: [PATCH] REBASE fix code grammar in fork_func() --- util/fork_func.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/util/fork_func.c b/util/fork_func.c index 71853c00..561f62d1 100644 --- a/util/fork_func.c +++ b/util/fork_func.c @@ -17,17 +17,18 @@ fork_func(int (* func)(void *), void * cookie) pid_t pid; /* Fork */ - if ((pid = fork()) == -1) { + switch (pid = fork()) { + case -1: warnp("fork"); goto err0; - } - if (pid == 0) { + case 0: /* In child process: Run the provided function, then exit. */ _exit((*func)(cookie)); + default: + /* In parent process: do nothing else. */ + break; } - /* In parent process: do nothing else. */ - /* Success! */ return (pid); @@ -68,7 +69,7 @@ fork_func_wait(pid_t pid) warn0("pid %jd: stopped with %i", (intmax_t)pid, WSTOPSIG(status)); else - warn0("pid %jd: stopped for unknown reason."); + warn0("pid %jd: exited for unknown reason."); } err0: