Commit 59e62d95 authored by Max Kellermann's avatar Max Kellermann

daemon: added comments to daemonize_detach()

parent 42415592
......@@ -131,18 +131,27 @@ daemonize_detach(void)
{
pid_t pid;
/* flush all file handles before duplicating the buffers */
fflush(NULL);
/* detach from parent process */
pid = fork();
if (pid < 0)
g_error("fork() failed: %s", g_strerror(errno));
if (pid > 0)
/* exit the parent process */
_exit(EXIT_SUCCESS);
/* release the current working directory */
if (chdir("/") < 0)
g_error("problems changing to root directory");
/* detach from the current session */
setsid();
g_debug("daemonized!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment