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

Function install_cleanup

src/timeout.c:436–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434}
435
436static void
437install_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.

Callers 1

mainFunction · 0.85

Calls 2

sig_needs_handlingFunction · 0.85
sigactionClass · 0.70

Tested by

no test coverage detected