| 434 | } |
| 435 | |
| 436 | static void |
| 437 | install_cleanup (int sigterm) |
| 438 | { |
| 439 | struct sigaction sa; |
| 440 | sigemptyset (&sa.sa_mask); /* Allow concurrent calls to handler */ |
| 441 | sa.sa_handler = cleanup; |
| 442 | sa.sa_flags = SA_RESTART; /* Restart syscalls if possible, as that's |
| 443 | more likely to work cleanly. */ |
| 444 | |
| 445 | for (int i = 0; i < countof (term_sig); i++) |
| 446 | if (sig_needs_handling (term_sig[i], sigterm)) |
| 447 | sigaction (term_sig[i], &sa, NULL); |
| 448 | |
| 449 | /* Real Time signals also terminate by default. */ |
| 450 | for (int s = SIGRTMIN; s <= SIGRTMAX; s++) |
| 451 | if (sig_needs_handling (s, sigterm)) |
| 452 | sigaction (s, &sa, NULL); |
| 453 | |
| 454 | sigaction (sigterm, &sa, NULL); /* user specified termination signal. */ |
| 455 | } |
| 456 | |
| 457 | /* Block all signals which were registered with cleanup() as the signal |
| 458 | handler, so we never kill processes after waitpid() returns. |
no test coverage detected