Seth Woolley's Man Viewer

Manual for signal - man 2 signal

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

SIGNAL(2)                  Linux Programmer's Manual                 SIGNAL(2)

       signal(2,7) - ANSI C signal(2,7) handling

       #include <signal.h>

       typedef void (*sighandler_t)(int);

       sighandler_t signal(2,7)(int signum, sighandler_t handler);

       The  signal(2,7)()  system call installs a new signal(2,7) handler for the signal(2,7)
       with number signum.  The signal(2,7) handler is set(7,n,1 builtins) to sighandler which  may
       be a user specified function, or either SIG_IGN or SIG_DFL.

       Upon  arrival of a signal(2,7) with number signum the following happens.  If
       the corresponding handler  is  set(7,n,1 builtins)  to  SIG_IGN,  then  the  signal(2,7)  is
       ignored.   If  the  handler  is set(7,n,1 builtins) to SIG_DFL, then the default action
       associated to the signal(2,7) (see signal(2,7)(7)) occurs.  Finally, if(3,n) the  han-
       dler  is  set(7,n,1 builtins) to a function sighandler then first either the handler is
       reset(1,7,1 tput) to SIG_DFL or an implementation-dependent blocking of the  signal(2,7)
       is performed and next sighandler is called with argument signum.

       Using  a  signal(2,7)  handler function for a signal(2,7) is called "catching the
       signal(2,7)".  The signals SIGKILL and SIGSTOP cannot be caught or  ignored.

       The signal(2,7)() function returns the previous value of the signal(2,7) handler,
       or SIG_ERR on error.

       The original Unix signal(2,7)() would reset(1,7,1 tput) the handler to SIG_DFL, and Sys-
       tem  V  (and the Linux kernel and libc4,5) does the same.  On the other
       hand, BSD does not reset(1,7,1 tput) the handler, but blocks new instances of  this
       signal(2,7) from occurring during a call of the handler.  The glibc2 library
       follows the BSD behaviour.

       If one on a libc5 system includes <bsd/signal.h> instead of  <signal.h>
       then  signal(2,7) is redefined as __bsd_signal and signal(2,7) has the BSD seman-
       tics. This is not recommended.

       If one on a  glibc2  system  defines  a  feature  test  macro  such  as
       _XOPEN_SOURCE  or  uses  a  separate  sysv_signal function, one obtains
       classical behaviour. This is not recommended.

       Trying to change the semantics of this call using defines and  includes
       is  not  a  good idea. It is better to avoid signal(2,7) altogether, and use
       sigaction(2) instead.

       The effects of this call in(1,8) a multi-threaded process are unspecified.

       The routine handler must be very careful,  since  processing  elsewhere
       was interrupted at some arbitrary point. POSIX has the concept of "safe
       function".  If a signal(2,7) interrupts  an  unsafe  function,  and  handler
       calls  an  unsafe  function, then the behavior is undefined. Safe func-
       tions are listed  explicitly  in(1,8)  the  various  standards.   The  POSIX
       1003.1-2003 list is

       _Exit()  _exit()  abort(3,7)()  accept(2,8)()  access(2,5)()  aio_error() aio_return()
       aio_suspend() alarm(1,2)() bind(2,n,1 builtins)() cfgetispeed() cfgetospeed()  cfsetispeed()
       cfsetospeed() chdir() chmod(1,2)() chown(1,2)() clock_gettime() close(2,7,n)() connect()
       creat() dup() dup2() execle() execve() fchmod() fchown() fcntl() fdata-
       sync(1,2,8)()   fork()   fpathconf()  fstat()  fsync()  ftruncate()  getegid()
       geteuid() getgid() getgroups() getpeername(1,2)() getpgrp()  getpid()  getp-
       pid()   getsockname()  getsockopt()  getuid()  kill(1,2,1 builtins)()  link(1,2)()  listen(1,2,7)()
       lseek() lstat()  mkdir(1,2)()  mkfifo(1,3)()  open(2,3,n)()  pathconf()  pause()  pipe(2,8)()
       poll()  posix_trace_event()  pselect() raise(3,n)() read(2,n,1 builtins)() readlink(1,2)() recv()
       recvfrom()  recvmsg()  rename(1,2,n)()  rmdir(1,2)()  select(2,7,2 select_tut)()  sem_post()   send(2,n)()
       sendmsg()  sendto()  setgid()  setpgid() setsid(2,8)() setsockopt() setuid()
       shutdown(2,8)()  sigaction()  sigaddset()  sigdelset()  sigemptyset()   sig-
       fillset()  sigismember() signal(2,7)() sigpause() sigpending() sigprocmask()
       sigqueue() sigset() sigsuspend() sleep(1,3)() socket(2,7,n)()  socketpair()  stat(1,2)()
       symlink()  sysconf()  tcdrain()  tcflow() tcflush() tcgetattr() tcgetp-
       grp() tcsendbreak() tcsetattr() tcsetpgrp()  time(1,2,n)()  timer_getoverrun()
       timer_gettime()   timer_settime()   times()  umask()  uname(1,2)()  unlink(1,2)()
       utime() wait() waitpid() write(1,2)().

       According to POSIX, the behaviour of a process is  undefined  after  it
       ignores  a  SIGFPE, SIGILL, or SIGSEGV signal(2,7) that was not generated by
       the kill(1,2,1 builtins)(2) or the raise(3,n)(3) functions.  Integer division  by  zero  has
       undefined result.  On some architectures it will generate a SIGFPE sig-
       nal.  (Also dividing the most  negative  integer  by  -1  may  generate
       SIGFPE.)  Ignoring this signal(2,7) might lead to an endless loop.

       According  to  POSIX  (  it  is  unspecified  what happens when
       SIGCHLD is set(7,n,1 builtins) to SIG_IGN.  Here the BSD and  SYSV  behaviours  differ,
       causing  BSD  software  that  sets the action for SIGCHLD to SIG_IGN to
       fail on Linux.

       The use of sighandler_t is a GNU extension.  Various versions  of  libc
       predefine  this  type;  libc4  and  libc5  define  SignalHandler, glibc
       defines sig_t and, when _GNU_SOURCE is defined, also sighandler_t.

       ANSI C

       kill(1,2,1 builtins)(1),  alarm(1,2)(2),   kill(1,2,1 builtins)(2),   killpg(2,3)(2),   pause(2),   sigaction(2),
       sigvec(2), raise(3,n)(3), sigsetops(3), signal(2,7)(7)

Linux 2.2                         2000-04-28                         SIGNAL(2)

References for this manual (incoming links)