Integrated websocket communication with hpws (#3)

This commit is contained in:
Chalith Desaman
2021-06-03 11:05:22 +05:30
committed by GitHub
parent 220d65bd0b
commit c0e743a6f4
14 changed files with 1455 additions and 63 deletions

View File

@@ -97,4 +97,35 @@ namespace util
return buffer.data();
}
/**
* Clears signal mask and signal handlers from the caller.
* Called by other processes forked from sagent threads so they get detatched from
* the sagent signal setup.
*/
void fork_detach()
{
// Restore signal handlers to defaults.
signal(SIGINT, SIG_DFL);
signal(SIGSEGV, SIG_DFL);
signal(SIGABRT, SIG_DFL);
// Remove any signal masks applied by sagent.
sigset_t mask;
sigemptyset(&mask);
pthread_sigmask(SIG_SETMASK, &mask, NULL);
// Set process group id (so the terminal doesn't send kill signals to forked children).
setpgrp();
}
// Applies signal mask to the calling thread.
void mask_signal()
{
sigset_t mask;
sigemptyset(&mask);
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGPIPE);
pthread_sigmask(SIG_BLOCK, &mask, NULL);
}
} // namespace util