2594
return sigprocmask(SIG_BLOCK, &SignalMask, &g_originalSignals);
2595
}
2596
2597
+// Returns true for signals that should not be saved/restored:
2598
+// SIGKILL/SIGSTOP — not settable per POSIX.
2599
+// SIGCONT — left at default to allow process resumption.
2600
+// SIGHUP — handled separately by the caller.
2601
+// 32-34 — internal NPTL signals (__SIGRTMIN through __SIGRTMIN+2) reserved
2602
+// by glibc for thread cancellation and other runtime use.
2603
+static bool SkipSignal(unsigned int Signal)
2604
+{
2605
+ switch (Signal)
2606
+ {
2607
+ case SIGKILL:
2608
+ case SIGSTOP:
2609
+ case SIGCONT:
2610
+ case SIGHUP:
2611
+ case 32:
2612
+ case 33:
2613
+ case 34:
2614
+ return true;
2615
+
2616
+ default:
2617
+ return false;
2618
+ }
2619
+}
2620
+
2621
int UtilSaveSignalHandlers(struct sigaction* SavedSignalActions)
2622
2623
/*++
2624
2625
Routine Description:
2626
2603
- This routine saves all settable signal handlers except SIGHUP.
2627
+ This routine saves all settable signal handlers, skipping signals
2628
+ listed in SkipSignal() (non-settable, SIGHUP, and internal NPTL signals).
2629
2630
Arguments:
2631
2640
{
2641
for (unsigned int Index = 1; Index < _NSIG; Index += 1)
2642
{
2618
- switch (Index)
2643
+ if (SkipSignal(Index))
2644
{
2620
- case SIGKILL:
2621
- case SIGSTOP:
2622
- case SIGCONT:
2623
- case SIGHUP:
2624
- case 32:
2625
- case 33:
2626
- case 34:
2645
continue;
2646
}
2647
2660
2661
Routine Description:
2662
2645
- This routine sets all settable signal handlers except SIGHUP to the given
2646
- handler.
2663
+ This routine sets all settable signal handlers to the given handler,
2664
+ skipping signals listed in SkipSignal().
2665
2666
Arguments:
2667
2680
2681
for (unsigned int Index = 1; Index < _NSIG; Index += 1)
2682
{
2665
- switch (Index)
2683
+ if (SkipSignal(Index))
2684
{
2667
- case SIGKILL:
2668
- case SIGSTOP:
2669
- case SIGCONT:
2670
- case SIGHUP:
2671
- case 32:
2672
- case 33:
2673
- case 34:
2685
continue;
2686
}
2687