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
18const char *
19SysSignal::Name(int signal)
20{
21    switch (signal)
22    {
23    case SIGHUP:    return "SIGHUP";    // 1    hangup
24    case SIGINT:    return "SIGINT";    // 2    interrupt
25    case SIGQUIT:   return "SIGQUIT";   // 3    quit
26    case SIGILL:    return "SIGILL";    // 4    illegal instruction (not reset when caught)
27    case SIGTRAP:   return "SIGTRAP";   // 5    trace trap (not reset when caught)
28    case SIGABRT:   return "SIGABRT";   // 6    abort()
29#if  defined(_POSIX_C_SOURCE)
30    case SIGPOLL:   return "SIGPOLL";   // 7    pollable event ([XSR] generated, not supported)
31#else    // !_POSIX_C_SOURCE
32    case SIGEMT:    return "SIGEMT";    // 7    EMT instruction
33#endif    // !_POSIX_C_SOURCE
34    case SIGFPE:    return "SIGFPE";    // 8    floating point exception
35    case SIGKILL:   return "SIGKILL";   // 9    kill (cannot be caught or ignored)
36    case SIGBUS:    return "SIGBUS";    // 10    bus error
37    case SIGSEGV:   return "SIGSEGV";   // 11    segmentation violation
38    case SIGSYS:    return "SIGSYS";    // 12    bad argument to system call
39    case SIGPIPE:   return "SIGPIPE";   // 13    write on a pipe with no one to read it
40    case SIGALRM:   return "SIGALRM";   // 14    alarm clock
41    case SIGTERM:   return "SIGTERM";   // 15    software termination signal from kill
42    case SIGURG:    return "SIGURG";    // 16    urgent condition on IO channel
43    case SIGSTOP:   return "SIGSTOP";   // 17    sendable stop signal not from tty
44    case SIGTSTP:   return "SIGTSTP";   // 18    stop signal from tty
45    case SIGCONT:   return "SIGCONT";   // 19    continue a stopped process
46    case SIGCHLD:   return "SIGCHLD";   // 20    to parent on child stop or exit
47    case SIGTTIN:   return "SIGTTIN";   // 21    to readers pgrp upon background tty read
48    case SIGTTOU:   return "SIGTTOU";   // 22    like TTIN for output if (tp->t_local&LTOSTOP)
49#if  !defined(_POSIX_C_SOURCE)
50    case SIGIO:     return "SIGIO";     // 23    input/output possible signal
51#endif
52    case SIGXCPU:   return "SIGXCPU";   // 24    exceeded CPU time limit
53    case SIGXFSZ:   return "SIGXFSZ";   // 25    exceeded file size limit
54    case SIGVTALRM: return "SIGVTALRM"; // 26    virtual time alarm
55    case SIGPROF:   return "SIGPROF";   // 27    profiling time alarm
56#if  !defined(_POSIX_C_SOURCE)
57    case SIGWINCH:  return "SIGWINCH";  // 28    window size changes
58    case SIGINFO:   return "SIGINFO";   // 29    information request
59#endif
60    case SIGUSR1:   return "SIGUSR1";   // 30    user defined signal 1
61    case SIGUSR2:   return "SIGUSR2";   // 31    user defined signal 2
62    default:
63        break;
64    }
65    return NULL;
66}
67