Overview Of Unix/Linux Signals


Each signal has a default action associated with it, which determines how the process behaves when it is delivered to the signal.

Some of the actions are −

  • Terminate the process.
  • Ignore the signal.
  • Dump core. This creates a file called process core dump.
  • Stop the process.
  • Continue a stopped process

How to send a signal to a program or script?

  • CTRL+C >Send  SIGINT
  • kill -signal <PID>

You can check  all signals  type with  “kill -l”  command.

# kill -l

1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL

5) SIGTRAP      6) SIGABRT      7) SIGEMT       8) SIGFPE

9) SIGKILL     10) SIGBUS      11) SIGSEGV     12) SIGSYS

13) SIGPIPE     14) SIGALRM     15) SIGTERM     16) SIGUSR1

17) SIGUSR2     18) SIGCHLD     19) SIGPWR      20) SIGWINCH

21) SIGURG      22) SIGIO       23) SIGSTOP     24) SIGTSTP

25) SIGCONT     26) SIGTTIN     27) SIGTTOU     28) SIGVTALRM

29) SIGPROF     30) SIGXCPU     31) SIGXFSZ     32) SIGWAITING

33) SIGLWP      34) SIGFREEZE   35) SIGTHAW     36) SIGCANCEL

37) SIGLOST     38) SIGXRES     41) SIGRTMIN    42) SIGRTMIN+1

43) SIGRTMIN+2  44) SIGRTMIN+3  45) SIGRTMAX-3  46) SIGRTMAX-2

47) SIGRTMAX-1  48) SIGRTMAX

Use  “trap” command to;

  • cleanup temporary files
  • Ignore signals

How to use “trap” signals?

With trap command, you can ignore signals or clean up temporary files.

#trap command signals

Example:trap “rm -f $WORKDIR/tmp1  $WORKDIR/tmp2 ; exit” 2    //user send interrupts execution of the program,this  two files  ‘ll be removed.
SIGHUP 1 Exit Hangup
SIGINT 2 Exit Interrupt
SIGQUIT 3 Core Quit
SIGILL 4 Core Illegal Instruction
SIGTRAP 5 Core Trace/Breakpoint Trap
SIGABRT 6 Core Abort
SIGEMT 7 Core Emulation Trap
SIGFPE 8 Core Arithmetic Exception
SIGKILL 9 Exit Killed
SIGBUS 10 Core Bus Error
SIGSEGV 11 Core Segmentation Fault
SIGSYS 12 Core Bad System Call
SIGPIPE 13 Exit Broken Pipe
SIGALRM 14 Exit Alarm Clock
SIGTERM 15 Exit Terminated
SIGUSR1 16 Exit User Signal 1
SIGUSR2 17 Exit User Signal 2
SIGCHLD 18 Ignore Child Status
SIGPWR 19 Ignore Power Fail/Restart
SIGWINCH 20 Ignore Window Size Change
SIGURG 21 Ignore Urgent Socket Condition
SIGPOLL 22 Ignore Socket I/O Possible
SIGSTOP 23 Stop Stopped (signal)
SIGTSTP 24 Stop Stopped (user)
SIGCONT 25 Ignore Continued
SIGTTIN 26 Stop Stopped (tty input)
SIGTTOU 27 Stop Stopped (tty output)
SIGVTALRM 28 Exit Virtual Timer Expired
SIGPROF 29 Exit Profiling Timer Expired
SIGXCPU 30 Core CPU time limit exceeded
SIGXFSZ 31 Core File size limit exceeded
SIGWAITING 32 Ignore All LWPs blocked
SIGLWP 33 Ignore Virtual Interprocessor Interrupt for Threads Library
SIGAIO 34 Ignore Asynchronous I/O

 

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me