Skip to content
Snippets Groups Projects
Commit f8d29f6f authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

A follow up for the patch for Bug#750658.

Check that --background actually works, fix
the coding style.
parent 58c6dd36
No related branches found
No related tags found
No related merge requests found
......@@ -316,32 +316,32 @@ create_pid(void)
fclose(f);
}
/** Run in the background.
*/
static void background()
/** Run in the background. */
static void
background()
{
switch (fork()) {
case -1:
goto error;
case 0: /* child */
break;
default: /* parent */
exit(EXIT_SUCCESS);
}
if (setsid() == -1)
goto error;
/*
* Prints to stdout on failure, so got to be done before we
* close it.
*/
create_pid();
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
switch (fork()) {
case -1:
goto error;
case 0: /* child */
break;
default: /* parent */
exit(EXIT_SUCCESS);
}
if (setsid() == -1)
goto error;
/*
* Prints to stdout on failure, so got to be done before
* we close it.
*/
create_pid();
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
return;
error:
exit(EXIT_FAILURE);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment