Merge branch 'jb41671' into 'master'

[mapplauncherd] Fix race when in writing the daemon PID file and exiting. Contributes to JB#41671

See merge request mer-core/mapplauncherd!8
pull/1/head
Andrew den Exter 8 years ago
commit 41a44c5ab4

@ -522,7 +522,10 @@ void Daemon::daemonize()
// If we got a good PID, then we can exit the parent process.
if (pid > 0)
{
exit(EXIT_SUCCESS);
// Wait for the child fork to exit to ensure the PID has been written before a caller
// is notified of the exit.
waitpid(pid, NULL, 0);
_exit(EXIT_SUCCESS);
}
// Fork off the parent process: second fork
@ -541,7 +544,7 @@ void Daemon::daemonize()
fclose(pidFile);
}
exit(EXIT_SUCCESS);
_exit(EXIT_SUCCESS);
}
// Change the file mode mask

Loading…
Cancel
Save