brintos

brintos / llvm-project-archived public Read only

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