MCPcopy Create free account
hub / github.com/coreutils/coreutils / block_cleanup_and_chld

Function block_cleanup_and_chld

src/timeout.c:462–482  ·  view source on GitHub ↗

Block all signals which were registered with cleanup() as the signal handler, so we never kill processes after waitpid() returns. Also block SIGCHLD to ensure it doesn't fire between waitpid() polling and sigsuspend() waiting for a signal. Return original mask in OLD_SET. */

Source from the content-addressed store, hash-verified

460 waitpid() polling and sigsuspend() waiting for a signal.
461 Return original mask in OLD_SET. */
462static void
463block_cleanup_and_chld (int sigterm, sigset_t *old_set)
464{
465 sigset_t block_set;
466 sigemptyset (&block_set);
467
468 for (int i = 0; i < countof (term_sig); i++)
469 if (sig_needs_handling (term_sig[i], sigterm))
470 sigaddset (&block_set, term_sig[i]);
471
472 for (int s = SIGRTMIN; s <= SIGRTMAX; s++)
473 if (sig_needs_handling (s, sigterm))
474 sigaddset (&block_set, s);
475
476 sigaddset (&block_set, sigterm);
477
478 sigaddset (&block_set, SIGCHLD);
479
480 if (sigprocmask (SIG_BLOCK, &block_set, old_set) != 0)
481 error (0, errno, _("warning: sigprocmask"));
482}
483
484/* Try to disable core dumps for this process.
485 Return TRUE if successful, FALSE otherwise. */

Callers 1

mainFunction · 0.85

Calls 1

sig_needs_handlingFunction · 0.85

Tested by

no test coverage detected