Correct handling of reaper thread in forking binaries

This commit is contained in:
Thulinma 2021-04-21 17:56:16 +02:00
parent ddd9e8c67d
commit bffd81f27e
5 changed files with 33 additions and 2 deletions

View file

@ -475,10 +475,10 @@ int main(int argc, char **argv){
Controller::conf.activate();
uint64_t reTimer = 0;
while (Controller::conf.is_active){
Util::Procs::fork_prepare();
pid_t pid = fork();
if (pid == 0){
Util::Procs::handler_set = false;
Util::Procs::reaper_thread = 0;
Util::Procs::fork_complete();
{
struct sigaction new_action;
new_action.sa_sigaction = handleUSR1;
@ -488,6 +488,7 @@ int main(int argc, char **argv){
}
return main_loop(argc, argv);
}
Util::Procs::fork_complete();
if (pid == -1){
FAIL_MSG("Unable to spawn controller process!");
return 2;

View file

@ -157,8 +157,10 @@ namespace Mist {
config->activate();
uint64_t reTimer = 0;
while (config->is_active){
Util::Procs::fork_prepare();
pid_t pid = fork();
if (pid == 0){
Util::Procs::fork_complete();
if (playerLock){
//Re-init streamStatus, previously closed
char pageName[NAME_BUFFER_SIZE];
@ -173,6 +175,7 @@ namespace Mist {
if (!preRun()){return 0;}
return run();
}
Util::Procs::fork_complete();
if (pid == -1){
FAIL_MSG("Unable to spawn input process");
//We failed. Release the kra... semaphores!