/ os

POSIX Signals

First the signals described in the original POSIX.1-1990 standard.

   Signal     Value     Action   Comment
   ──────────────────────────────────────────────────────────────────────
   SIGHUP        1       Term    Hangup detected on controlling terminal
                                 or death of controlling process
   SIGINT        2       Term    Interrupt from keyboard
   SIGQUIT       3       Core    Quit from keyboard
   SIGILL        4       Core    Illegal Instruction
   SIGABRT       6       Core    Abort signal from abort(3)
   SIGFPE        8       Core    Floating-point exception
   SIGKILL       9       Term    Kill signal
   SIGSEGV      11       Core    Invalid memory reference
   SIGPIPE      13       Term    Broken pipe: write to pipe with no
                                 readers; see pipe(7)
   SIGALRM      14       Term    Timer signal from alarm(2)
   SIGTERM      15       Term    Termination signal
   SIGUSR1   30,10,16    Term    User-defined signal 1
   SIGUSR2   31,12,17    Term    User-defined signal 2
   SIGCHLD   20,17,18    Ign     Child stopped or terminated
   SIGCONT   19,18,25    Cont    Continue if stopped
   SIGSTOP   17,19,23    Stop    Stop process
   SIGTSTP   18,20,24    Stop    Stop typed at terminal
   SIGTTIN   21,21,26    Stop    Terminal input for background process
   SIGTTOU   22,22,27    Stop    Terminal output for background process

iOScrash 相关的几个 Signal

  1. SIGABRT
    why SIGABRT error?
    Why Do I Get An Error Called SIGABRT?

SIGABRT is commonly used by libc and other libraries to abort the progamm in case of critical errors. For example, glibc sends an SIGABRT in case of a detected double-free or other heap corruptions.
Also, most "assert" implementaions make use of SIGABRT in case of a failed assert.
Furthermore, SIGABRT can be send from any other process like any other signal. Of course, the sending process needs to run as same user or root.

  1. SIGSEGV
    Why Do I Get An Error Called SIGSEGV?

A SIGSEGV is an error(signal) caused by an invalid memory reference or a segmentation fault. You are probably trying to access an array element out of bounds or trying to use too much memory. Some of the other causes of a segmentation fault are : Using uninitialized pointers, dereference of NULL pointers, accessing memory that the program doesn’t own.

  1. SIGKILL

The SIGKILL signal is sent to a process to cause it to terminate immediately (kill). In contrast to SIGTERM and SIGINT, this signal cannot be caught or ignored, and the receiving process cannot perform any clean-up upon receiving this signal.

  1. SIGPIPE
    https://stackoverflow.com/questions/18935446/program-received-signal-sigpipe-broken-pipe

The process received a SIGPIPE. The default behaviour for this signal is to end the process.
A SIGPIPE is sent to a process if it tried to write to a socket that had been shutdown for writing or isn't connected (anymore).
To avoid that the program ends in this case, you could either
make the process ignore SIGPIPE or
install an explicit handler for SIGPIPE (typically doing nothing).
In both cases send*()/write() would return -1 and set errno to EPIPE.