Minor code refactor

This commit is contained in:
Andrew Bettison 2012-05-07 19:14:29 +09:30
parent 09f8434a21
commit 27f2d00d5e

View File

@ -607,8 +607,9 @@ int app_server_start(int argc, const char *const *argv, struct command_line_opti
if (foregroundP) if (foregroundP)
return server(NULL); return server(NULL);
switch ((pid = fork())) { switch ((pid = fork())) {
case 0: { case -1:
// Child process. return WHYF("fork() failed: %s [errno=%d]", strerror(errno), errno);
case 0: { // Child process.
chdir("/"); chdir("/");
close(0); close(0);
open("/dev/null", O_RDONLY); open("/dev/null", O_RDONLY);
@ -625,9 +626,7 @@ int app_server_start(int argc, const char *const *argv, struct command_line_opti
} }
return server(NULL); return server(NULL);
} }
case -1: default: { // Parent process
return WHYF("fork() failed: %s [errno=%d]", strerror(errno), errno);
default: {
/* Allow a few seconds for the process to start, and keep an eye on things while this is /* Allow a few seconds for the process to start, and keep an eye on things while this is
happening. */ happening. */
time_t timeout = time(NULL) + 5; time_t timeout = time(NULL) + 5;