| 1 | #include <signal.h> |
|---|---|
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | #include <unistd.h> |
| 5 | |
| 6 | void handler(int signo) |
| 7 | { |
| 8 | _exit(status: signo); |
| 9 | } |
| 10 | |
| 11 | int main (int argc, char *argv[]) |
| 12 | { |
| 13 | if (signal(SIGTRAP, handler: handler) == SIG_ERR) |
| 14 | { |
| 15 | perror(s: "signal(SIGTRAP)"); |
| 16 | return 1; |
| 17 | } |
| 18 | #ifndef __APPLE__ |
| 19 | // Real time signals not supported on apple platforms. |
| 20 | if (signal(SIGRTMIN, handler: handler) == SIG_ERR) |
| 21 | { |
| 22 | perror(s: "signal(SIGRTMIN)"); |
| 23 | return 1; |
| 24 | } |
| 25 | #endif |
| 26 | |
| 27 | if (argc < 2) |
| 28 | { |
| 29 | puts(s: "Please specify a signal to raise"); |
| 30 | return 1; |
| 31 | } |
| 32 | |
| 33 | if (strcmp(s1: argv[1], s2: "SIGSTOP") == 0) |
| 34 | raise(SIGSTOP); |
| 35 | else if (strcmp(s1: argv[1], s2: "SIGTRAP") == 0) |
| 36 | raise(SIGTRAP); |
| 37 | #ifndef __APPLE__ |
| 38 | else if (strcmp(s1: argv[1], s2: "SIGRTMIN") == 0) |
| 39 | raise(SIGRTMIN); |
| 40 | #endif |
| 41 | else |
| 42 | { |
| 43 | printf(format: "Unknown signal: %s\n", argv[1]); |
| 44 | return 1; |
| 45 | } |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 |
