1 //===-- SysSignal.cpp -------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  Created by Greg Clayton on 6/18/07.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "SysSignal.h"
15 #include <signal.h>
16 #include <stddef.h>
17 
18 const char *SysSignal::Name(int signal) {
19   switch (signal) {
20   case SIGHUP:
21     return "SIGHUP"; // 1    hangup
22   case SIGINT:
23     return "SIGINT"; // 2    interrupt
24   case SIGQUIT:
25     return "SIGQUIT"; // 3    quit
26   case SIGILL:
27     return "SIGILL"; // 4    illegal instruction (not reset when caught)
28   case SIGTRAP:
29     return "SIGTRAP"; // 5    trace trap (not reset when caught)
30   case SIGABRT:
31     return "SIGABRT"; // 6    abort()
32 #if defined(_POSIX_C_SOURCE)
33   case SIGPOLL:
34     return "SIGPOLL"; // 7    pollable event ([XSR] generated, not supported)
35 #else                 // !_POSIX_C_SOURCE
36   case SIGEMT:
37     return "SIGEMT"; // 7    EMT instruction
38 #endif                // !_POSIX_C_SOURCE
39   case SIGFPE:
40     return "SIGFPE"; // 8    floating point exception
41   case SIGKILL:
42     return "SIGKILL"; // 9    kill (cannot be caught or ignored)
43   case SIGBUS:
44     return "SIGBUS"; // 10    bus error
45   case SIGSEGV:
46     return "SIGSEGV"; // 11    segmentation violation
47   case SIGSYS:
48     return "SIGSYS"; // 12    bad argument to system call
49   case SIGPIPE:
50     return "SIGPIPE"; // 13    write on a pipe with no one to read it
51   case SIGALRM:
52     return "SIGALRM"; // 14    alarm clock
53   case SIGTERM:
54     return "SIGTERM"; // 15    software termination signal from kill
55   case SIGURG:
56     return "SIGURG"; // 16    urgent condition on IO channel
57   case SIGSTOP:
58     return "SIGSTOP"; // 17    sendable stop signal not from tty
59   case SIGTSTP:
60     return "SIGTSTP"; // 18    stop signal from tty
61   case SIGCONT:
62     return "SIGCONT"; // 19    continue a stopped process
63   case SIGCHLD:
64     return "SIGCHLD"; // 20    to parent on child stop or exit
65   case SIGTTIN:
66     return "SIGTTIN"; // 21    to readers pgrp upon background tty read
67   case SIGTTOU:
68     return "SIGTTOU"; // 22    like TTIN for output if (tp->t_local&LTOSTOP)
69 #if !defined(_POSIX_C_SOURCE)
70   case SIGIO:
71     return "SIGIO"; // 23    input/output possible signal
72 #endif
73   case SIGXCPU:
74     return "SIGXCPU"; // 24    exceeded CPU time limit
75   case SIGXFSZ:
76     return "SIGXFSZ"; // 25    exceeded file size limit
77   case SIGVTALRM:
78     return "SIGVTALRM"; // 26    virtual time alarm
79   case SIGPROF:
80     return "SIGPROF"; // 27    profiling time alarm
81 #if !defined(_POSIX_C_SOURCE)
82   case SIGWINCH:
83     return "SIGWINCH"; // 28    window size changes
84   case SIGINFO:
85     return "SIGINFO"; // 29    information request
86 #endif
87   case SIGUSR1:
88     return "SIGUSR1"; // 30    user defined signal 1
89   case SIGUSR2:
90     return "SIGUSR2"; // 31    user defined signal 2
91   default:
92     break;
93   }
94   return NULL;
95 }
96