95 lines · cpp
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-exception6//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 17const char *SysSignal::Name(int signal) {18 switch (signal) {19 case SIGHUP:20 return "SIGHUP"; // 1 hangup21 case SIGINT:22 return "SIGINT"; // 2 interrupt23 case SIGQUIT:24 return "SIGQUIT"; // 3 quit25 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_SOURCE35 case SIGEMT:36 return "SIGEMT"; // 7 EMT instruction37#endif // !_POSIX_C_SOURCE38 case SIGFPE:39 return "SIGFPE"; // 8 floating point exception40 case SIGKILL:41 return "SIGKILL"; // 9 kill (cannot be caught or ignored)42 case SIGBUS:43 return "SIGBUS"; // 10 bus error44 case SIGSEGV:45 return "SIGSEGV"; // 11 segmentation violation46 case SIGSYS:47 return "SIGSYS"; // 12 bad argument to system call48 case SIGPIPE:49 return "SIGPIPE"; // 13 write on a pipe with no one to read it50 case SIGALRM:51 return "SIGALRM"; // 14 alarm clock52 case SIGTERM:53 return "SIGTERM"; // 15 software termination signal from kill54 case SIGURG:55 return "SIGURG"; // 16 urgent condition on IO channel56 case SIGSTOP:57 return "SIGSTOP"; // 17 sendable stop signal not from tty58 case SIGTSTP:59 return "SIGTSTP"; // 18 stop signal from tty60 case SIGCONT:61 return "SIGCONT"; // 19 continue a stopped process62 case SIGCHLD:63 return "SIGCHLD"; // 20 to parent on child stop or exit64 case SIGTTIN:65 return "SIGTTIN"; // 21 to readers pgrp upon background tty read66 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 signal71#endif72 case SIGXCPU:73 return "SIGXCPU"; // 24 exceeded CPU time limit74 case SIGXFSZ:75 return "SIGXFSZ"; // 25 exceeded file size limit76 case SIGVTALRM:77 return "SIGVTALRM"; // 26 virtual time alarm78 case SIGPROF:79 return "SIGPROF"; // 27 profiling time alarm80#if !defined(_POSIX_C_SOURCE)81 case SIGWINCH:82 return "SIGWINCH"; // 28 window size changes83 case SIGINFO:84 return "SIGINFO"; // 29 information request85#endif86 case SIGUSR1:87 return "SIGUSR1"; // 30 user defined signal 188 case SIGUSR2:89 return "SIGUSR2"; // 31 user defined signal 290 default:91 break;92 }93 return NULL;94}95