diff --git a/sample_scenarios/scenario0 b/sample_scenarios/scenario0 index 3a42512..2403b35 100644 --- a/sample_scenarios/scenario0 +++ b/sample_scenarios/scenario0 @@ -1,6 +1,6 @@ -p sample_profiles/all_blue +p /etc/g810-led/sample_profiles/all_blue w 1000 -p sample_profiles/all_green +p /etc/g810-led/sample_profiles/all_green w 1000 -p sample_profiles/all_red +p /etc/g810-led/sample_profiles/all_red w 1000 diff --git a/src/helpers/daemonizer.cpp b/src/helpers/daemonizer.cpp index 5038f31..5640efa 100644 --- a/src/helpers/daemonizer.cpp +++ b/src/helpers/daemonizer.cpp @@ -17,16 +17,35 @@ namespace daemonizer { void start(char *arg0, std::string scenarioFile) { pid_t pid, sid; + + pid = fork(); + if (pid < 0) exit(EXIT_FAILURE); + if (pid > 0) exit(EXIT_SUCCESS); + sid = setsid(); + if (sid < 0) exit(EXIT_FAILURE); + signal(SIGCHLD,SIG_IGN); /* ignore child */ + signal(SIGHUP,SIG_IGN); /* ignore child */ + + pid = fork(); if (pid < 0) exit(EXIT_FAILURE); if (pid > 0) exit(EXIT_SUCCESS); umask(0); - sid = setsid(); - if (sid < 0) exit(EXIT_FAILURE); + if (chdir("/") < 0) exit(EXIT_FAILURE); - //signal(SIGINT, stop); std::cout<