mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Isolate child process group with setpgid to prevent double signal delivery
This commit is contained in:
parent
4defb748e8
commit
1c3f695d5a
1 changed files with 6 additions and 0 deletions
|
|
@ -387,6 +387,9 @@ int main(int argc, char* argv[])
|
|||
if (pid == 0) {
|
||||
/* child process */
|
||||
|
||||
/* isolate child in its own process group to prevent double signal delivery from terminal */
|
||||
setpgid(0, 0);
|
||||
|
||||
/* restore default signal handlers */
|
||||
signal(SIGINT, SIG_DFL);
|
||||
signal(SIGQUIT, SIG_DFL);
|
||||
|
|
@ -409,6 +412,9 @@ int main(int argc, char* argv[])
|
|||
/* parent process */
|
||||
int status;
|
||||
|
||||
/* set child process group in parent to prevent race condition */
|
||||
setpgid(pid, pid);
|
||||
|
||||
/* store child PID so signal handler can forward signals */
|
||||
child_pid = pid;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue