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

Function signal_setup

src/ls.c:1586–1633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1584 otherwise restore to the default. */
1585
1586static void
1587signal_setup (bool init)
1588{
1589 /* The signals that are trapped, and the number of such signals. */
1590 static int const stop_sig[] =
1591 {
1592 /* This one is handled specially. */
1593 SIGTSTP,
1594 };
1595
1596 enum { nsigs = countof (term_sig), nstop = countof (stop_sig) };
1597
1598 if (init)
1599 {
1600 struct sigaction act;
1601
1602 sigemptyset (&caught_signals);
1603 for (int j = 0; j < nsigs + nstop; j++)
1604 {
1605 int sig = j < nsigs ? term_sig[j]: stop_sig[j - nsigs];
1606 sigaction (sig, NULL, &act);
1607 if (act.sa_handler != SIG_IGN)
1608 sigaddset (&caught_signals, sig);
1609 }
1610
1611 act.sa_mask = caught_signals;
1612 act.sa_flags = SA_RESTART;
1613
1614 for (int j = 0; j < nsigs + nstop; j++)
1615 {
1616 int sig = j < nsigs ? term_sig[j]: stop_sig[j - nsigs];
1617 if (sigismember (&caught_signals, sig))
1618 {
1619 act.sa_handler = j < nsigs ? sighandler : stophandler;
1620 sigaction (sig, &act, NULL);
1621 }
1622 }
1623 }
1624 else /* restore. */
1625 {
1626 for (int j = 0; j < nsigs + nstop; j++)
1627 {
1628 int sig = j < nsigs ? term_sig[j]: stop_sig[j - nsigs];
1629 if (sigismember (&caught_signals, sig))
1630 signal (sig, SIG_DFL);
1631 }
1632 }
1633}
1634
1635static void
1636signal_init (void)

Callers 2

signal_initFunction · 0.85
signal_restoreFunction · 0.85

Calls 1

sigactionClass · 0.70

Tested by

no test coverage detected