mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
Fix shmmonitor daemonization
This commit is contained in:
parent
dd191551ca
commit
2c6f436858
|
@ -26,19 +26,25 @@ using namespace fair::mq::shmem;
|
||||||
static void daemonize()
|
static void daemonize()
|
||||||
{
|
{
|
||||||
// already a daemon?
|
// already a daemon?
|
||||||
// if (getppid() == 1) return;
|
if (getppid() == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Fork off the parent process
|
// Fork
|
||||||
// pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
// if (pid < 0) exit(1);
|
if (pid < 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// If we got a good PID, then we can exit the parent process.
|
// If we got a good PID, then we can exit the parent process.
|
||||||
// if (pid > 0) exit(0);
|
if (pid > 0) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
// Change the file mode mask
|
// Change the file mode mask
|
||||||
umask(0);
|
umask(0);
|
||||||
|
|
||||||
// Create a new SID for the child process
|
// Create a new session with the calling process as its leader.
|
||||||
if (setsid() < 0) {
|
if (setsid() < 0) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user