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