mirror of
https://github.com/EvernodeXRPL/sashimono.git
synced 2026-06-07 18:56:49 +00:00
Integrated websocket communication with hpws (#3)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user