1 /* Copyright 2016-2023 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 # define OUTPUT_TXT "output.txt"
29 perror_and_exit (const char *s
)
36 main (int argc
, char **argv
)
43 res
= sigprocmask (0, NULL
, &sigset
);
45 perror_and_exit ("sigprocmask");
51 out
= fopen (OUTPUT_TXT
, "w");
53 perror_and_exit ("fopen");
56 for (i
= 1; i
< NSIG
; i
++)
58 struct sigaction oldact
;
60 fprintf (out
, "signal %d: ", i
);
62 res
= sigaction (i
, NULL
, &oldact
);
63 if (res
== -1 && errno
== EINVAL
)
65 /* Some signal numbers in the range are invalid. E.g.,
66 signals 32 and 33 on GNU/Linux. */
67 fprintf (out
, "invalid");
71 perror_and_exit ("sigaction");
77 fprintf (out
, "sigaction={sa_handler=");
79 if (oldact
.sa_handler
== SIG_DFL
)
80 fprintf (out
, "SIG_DFL");
81 else if (oldact
.sa_handler
== SIG_IGN
)
82 fprintf (out
, "SIG_IGN");
86 fprintf (out
, ", sa_mask=");
87 for (m
= 1; m
< NSIG
; m
++)
88 fprintf (out
, "%c", sigismember (&oldact
.sa_mask
, m
) ? '1' : '0');
90 fprintf (out
, ", sa_flags=%d", oldact
.sa_flags
);
92 fprintf (out
, "}, masked=%d", sigismember (&sigset
, i
));