OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / original / man2 / sigaction.2
index 7fea1f8..74ef301 100644 (file)
@@ -3,6 +3,7 @@
 .\" and Copyright 2004, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
 .\" based on work by faith@cs.unc.edu
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
@@ -22,6 +23,7 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\" Modified, aeb, 960424
 .\" Modified Fri Jan 31 17:31:20 1997 by Eric S. Raymond <esr@thyrsus.com>
 .\"    out of this page into separate pages.
 .\" 2010-06-11 Andi Kleen, add hwpoison signal extensions
 .\" 2010-06-11 mtk, improvements to discussion of various siginfo_t fields.
+.\" 2015-01-17, Kees Cook <keescook@chromium.org>
+.\"    Added notes on ptrace SIGTRAP and SYS_SECCOMP.
 .\"
-.TH SIGACTION 2 2012-04-12 "Linux" "Linux Programmer's Manual"
+.TH SIGACTION 2 2015-01-22 "Linux" "Linux Programmer's Manual"
 .SH NAME
 sigaction \- examine and change a signal action
 .SH SYNOPSIS
@@ -61,6 +65,9 @@ Feature Test Macro Requirements for glibc (see
 .ad l
 .BR sigaction ():
 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
+
+.IR siginfo_t :
+_POSIX_C_SOURCE >= 199309L
 .ad b
 .SH DESCRIPTION
 The
@@ -111,10 +118,12 @@ and
 .PP
 The
 .I sa_restorer
-element is obsolete and should not be used.
-POSIX does not specify a
+field is not intended for application use.
+(POSIX does not specify a
 .I sa_restorer
-element.
+field.)
+Some further details of purpose of this field can be found in
+.BR sigreturn (2).
 .PP
 .I sa_handler
 specifies the action to be associated with
@@ -144,7 +153,7 @@ as its second argument and a pointer to a
 (cast to \fIvoid\ *\fP) as its third argument.
 (Commonly, the handler function doesn't make any use of the third argument.
 See
-.BR getcontext (2)
+.BR getcontext (3)
 for further information about
 .IR ucontext_t .)
 .PP
@@ -170,14 +179,14 @@ is
 .BR SIGCHLD ,
 do not receive notification when child processes stop (i.e., when they
 receive one of
-.BR SIGSTOP ", " SIGTSTP ", " SIGTTIN
+.BR SIGSTOP ", " SIGTSTP ", " SIGTTIN ", "
 or
 .BR SIGTTOU )
 or resume (i.e., they receive
 .BR SIGCONT )
 (see
 .BR wait (2)).
-This flag is only meaningful when establishing a handler for
+This flag is meaningful only when establishing a handler for
 .BR SIGCHLD .
 .TP
 .BR SA_NOCLDWAIT " (since Linux 2.6)"
@@ -189,7 +198,7 @@ is
 do not transform children into zombies when they terminate.
 See also
 .BR waitpid (2).
-This flag is only meaningful when establishing a handler for
+This flag is meaningful only when establishing a handler for
 .BR SIGCHLD ,
 or when setting that signal's disposition to
 .BR SIG_DFL .
@@ -209,7 +218,7 @@ on some other implementations, it is not.
 .B SA_NODEFER
 Do not prevent the signal from being received from within its own signal
 handler.
-This flag is only meaningful when establishing a signal handler.
+This flag is meaningful only when establishing a signal handler.
 .B SA_NOMASK
 is an obsolete, nonstandard synonym for this flag.
 .TP
@@ -217,30 +226,38 @@ is an obsolete, nonstandard synonym for this flag.
 Call the signal handler on an alternate signal stack provided by
 .BR sigaltstack (2).
 If an alternate stack is not available, the default stack will be used.
-This flag is only meaningful when establishing a signal handler.
+This flag is meaningful only when establishing a signal handler.
 .TP
 .BR SA_RESETHAND
-Restore the signal action to the default state once the signal handler
-has been called.
-This flag is only meaningful when establishing a signal handler.
+Restore the signal action to the default upon entry to the signal handler.
+This flag is meaningful only when establishing a signal handler.
 .B SA_ONESHOT
 is an obsolete, nonstandard synonym for this flag.
 .TP
 .B SA_RESTART
 Provide behavior compatible with BSD signal semantics by making certain
 system calls restartable across signals.
-This flag is only meaningful when establishing a signal handler.
+This flag is meaningful only when establishing a signal handler.
 See
 .BR signal (7)
 for a discussion of system call restarting.
 .TP
+.BR SA_RESTORER
+.IR "Not intended for application use" .
+This flag is used by C libraries to indicate that the
+.IR sa_restorer
+field contains the address of a "signal trampoline".
+See
+.BR sigreturn (2)
+for more details.
+.TP
 .BR SA_SIGINFO " (since Linux 2.2)"
-The signal handler takes 3 arguments, not one.
+The signal handler takes three arguments, not one.
 In this case,
 .I sa_sigaction
 should be set instead of
 .IR sa_handler .
-This flag is only meaningful when establishing a signal handler.
+This flag is meaningful only when establishing a signal handler.
 .\" (The
 .\" .I sa_sigaction
 .\" field was added in Linux 2.1.86.)
@@ -250,37 +267,44 @@ The
 .I siginfo_t
 argument to
 .I sa_sigaction
-is a struct with the following elements:
+is a struct with the following fields:
 .sp
 .in +4n
 .nf
 siginfo_t {
-    int      si_signo;    /* Signal number */
-    int      si_errno;    /* An errno value */
-    int      si_code;     /* Signal code */
-    int      si_trapno;   /* Trap number that caused
-                             hardware-generated signal
-                             (unused on most architectures) */
+    int      si_signo;     /* Signal number */
+    int      si_errno;     /* An errno value */
+    int      si_code;      /* Signal code */
+    int      si_trapno;    /* Trap number that caused
+                              hardware-generated signal
+                              (unused on most architectures) */
 .\" FIXME
-.\" si_trapno seems to be only used on SPARC and Alpha;
+.\" The siginfo_t 'si_trapno' field seems to be used only on SPARC and Alpha;
 .\" this page could use a little more detail on its purpose there.
-    pid_t    si_pid;      /* Sending process ID */
-    uid_t    si_uid;      /* Real user ID of sending process */
-    int      si_status;   /* Exit value or signal */
-    clock_t  si_utime;    /* User time consumed */
-    clock_t  si_stime;    /* System time consumed */
-    sigval_t si_value;    /* Signal value */
-    int      si_int;      /* POSIX.1b signal */
-    void    *si_ptr;      /* POSIX.1b signal */
-    int      si_overrun;  /* Timer overrun count; POSIX.1b timers */
-    int      si_timerid;  /* Timer ID; POSIX.1b timers */
+    pid_t    si_pid;       /* Sending process ID */
+    uid_t    si_uid;       /* Real user ID of sending process */
+    int      si_status;    /* Exit value or signal */
+    clock_t  si_utime;     /* User time consumed */
+    clock_t  si_stime;     /* System time consumed */
+    sigval_t si_value;     /* Signal value */
+    int      si_int;       /* POSIX.1b signal */
+    void    *si_ptr;       /* POSIX.1b signal */
+    int      si_overrun;   /* Timer overrun count;
+                              POSIX.1b timers */
+    int      si_timerid;   /* Timer ID; POSIX.1b timers */
 .\" In the kernel: si_tid
-    void    *si_addr;     /* Memory location which caused fault */
-    long     si_band;     /* Band event (was \fIint\fP in
-                             glibc 2.3.2 and earlier) */
-    int      si_fd;       /* File descriptor */
-    short    si_addr_lsb; /* Least significant bit of address
-                             (since kernel 2.6.32) */
+    void    *si_addr;      /* Memory location which caused fault */
+    long     si_band;      /* Band event (was \fIint\fP in
+                              glibc 2.3.2 and earlier) */
+    int      si_fd;        /* File descriptor */
+    short    si_addr_lsb;  /* Least significant bit of address
+                              (since Linux 2.6.32) */
+    void    *si_call_addr; /* Address of system call instruction
+                              (since Linux 3.5) */
+    int      si_syscall;   /* Number of attempted system call
+                              (since Linux 3.5) */
+    unsigned int si_arch;  /* Architecture of attempted system call
+                              (since Linux 3.5) */
 }
 .fi
 .in
@@ -289,8 +313,8 @@ siginfo_t {
 are defined for all signals.
 .RI ( si_errno
 is generally unused on Linux.)
-The rest of the struct may be a union, so that one should only
-read the fields that are meaningful for the given signal:
+The rest of the struct may be a union, so that one should
+read only the fields that are meaningful for the given signal:
 .IP * 2
 Signals sent with
 .BR kill (2)
@@ -340,7 +364,7 @@ with the real user ID of the message sender.
 .IP *
 .B SIGCHLD
 fills in
-.IR si_pid ", " si_uid ", " si_status ", " si_utime " and " si_stime ,
+.IR si_pid ", " si_uid ", " si_status ", " si_utime ", and " si_stime ,
 providing information about the child.
 The
 .I si_pid
@@ -362,7 +386,7 @@ contain the user and system CPU time used by the child process;
 these fields do not include the times used by waited-for children (unlike
 .BR getrusage (2)
 and
-.BR time (2)).
+.BR times (2)).
 In kernels up to 2.6, and since 2.6.27, these fields report
 CPU time in units of
 .IR sysconf(_SC_CLK_TCK) .
@@ -394,14 +418,10 @@ and
 fill in
 .I si_addr
 with the address of the fault.
-.\" FIXME SIGTRAP also sets the following for ptrace_notify() ?
-.\"     info.si_code = exit_code;
-.\"     info.si_pid = task_pid_vnr(current);
-.\"     info.si_uid = current_uid();  /* Real UID */
 On some architectures,
 these signals also fill in the
 .I si_trapno
-filed.
+field.
 Some suberrors of
 .BR SIGBUS ,
 in particular
@@ -416,7 +436,22 @@ For example, if a full page was corrupted,
 .I si_addr_lsb
 contains
 .IR log2(sysconf(_SC_PAGESIZE)) .
-.B BUS_MCERR_*
+When
+.BR SIGTRAP
+is delivered in response to a
+.BR ptrace (2)
+event (PTRACE_EVENT_foo),
+.I si_addr
+is not populated, but
+.I si_pid
+and
+.I si_uid
+are populated with the respective process ID and user ID responsible for
+delivering the trap.
+In the case of
+.BR seccomp (2),
+the tracee will be shown as delivering the event.
+.B BUS_MCEERR_*
 and
 .I si_addr_lsb
 are Linux-specific extensions.
@@ -434,35 +469,58 @@ field by
 The
 .I si_fd
 field indicates the file descriptor for which the I/O event occurred.
+.IP *
+.BR SIGSYS ,
+generated (since Linux 3.5)
+.\" commit a0727e8ce513fe6890416da960181ceb10fbfae6
+when a seccomp filter returns
+.BR SECCOMP_RET_TRAP ,
+fills in
+.IR si_call_addr ,
+.IR si_syscall ,
+.IR si_arch ,
+.IR si_errno ,
+and other fields as described in
+.BR seccomp (2).
 .PP
 .I si_code
-is a value (not a bit mask)
-indicating why this signal was sent.
-The following list shows the values which can be placed in
+is a value (not a bit mask) indicating why this signal was sent.
+For a
+.BR ptrace (2)
+event,
+.I si_code
+will contain
+.BR SIGTRAP
+and have the ptrace event in the high byte:
+
+.nf
+    (SIGTRAP | PTRACE_EVENT_foo << 8).
+.fi
+
+For a regular signal, the following list shows the values which can be
+placed in
 .I si_code
 for any signal, along with reason that the signal was generated.
 .RS 4
-.TP 15
+.TP
 .B SI_USER
-.BR kill (2)
-or
-.BR raise (3)
+.BR kill (2).
 .TP
 .B SI_KERNEL
 Sent by the kernel.
 .TP
 .B SI_QUEUE
-.BR sigqueue (3)
+.BR sigqueue (3).
 .TP
 .B SI_TIMER
-POSIX timer expired
+POSIX timer expired.
 .TP
-.B SI_MESGQ
-POSIX message queue state changed (since Linux 2.6.6); see
-.BR mq_notify (3)
+.BR SI_MESGQ " (since Linux 2.6.6)"
+POSIX message queue state changed; see
+.BR mq_notify (3).
 .TP
 .B SI_ASYNCIO
-AIO completed
+AIO completed.
 .TP
 .B SI_SIGIO
 Queued
@@ -473,11 +531,10 @@ fills in
 .I si_code
 as described below).
 .TP
-.B SI_TKILL
+.BR SI_TKILL " (since Linux 2.4.19)"
 .BR tkill (2)
 or
-.BR tgkill (2)
-(since Linux 2.4.19)
+.BR tgkill (2).
 .\" SI_DETHREAD is defined in 2.6.9 sources, but isn't implemented
 .\" It appears to have been an idea that was tried during 2.5.6
 .\" through to 2.5.24 and then was backed out.
@@ -489,30 +546,30 @@ for a
 .B SIGILL
 signal:
 .RS 4
-.TP 15
+.TP
 .B ILL_ILLOPC
-illegal opcode
+Illegal opcode.
 .TP
 .B ILL_ILLOPN
-illegal operand
+Illegal operand.
 .TP
 .B ILL_ILLADR
-illegal addressing mode
+Illegal addressing mode.
 .TP
 .B ILL_ILLTRP
-illegal trap
+Illegal trap.
 .TP
 .B ILL_PRVOPC
-privileged opcode
+Privileged opcode.
 .TP
 .B ILL_PRVREG
-privileged register
+Privileged register.
 .TP
 .B ILL_COPROC
-coprocessor error
+Coprocessor error.
 .TP
 .B ILL_BADSTK
-internal stack error
+Internal stack error.
 .RE
 .PP
 The following values can be placed in
@@ -521,30 +578,30 @@ for a
 .B SIGFPE
 signal:
 .RS 4
-.TP 15
+.TP
 .B FPE_INTDIV
-integer divide by zero
+Integer divide by zero.
 .TP
 .B FPE_INTOVF
-integer overflow
+Integer overflow.
 .TP
 .B FPE_FLTDIV
-floating-point divide by zero
+Floating-point divide by zero.
 .TP
 .B FPE_FLTOVF
-floating-point overflow
+Floating-point overflow.
 .TP
 .B FPE_FLTUND
-floating-point underflow
+Floating-point underflow.
 .TP
 .B FPE_FLTRES
-floating-point inexact result
+Floating-point inexact result.
 .TP
 .B FPE_FLTINV
-floating-point invalid operation
+Floating-point invalid operation.
 .TP
 .B FPE_FLTSUB
-subscript out of range
+Subscript out of range.
 .RE
 .PP
 The following values can be placed in
@@ -553,12 +610,12 @@ for a
 .B SIGSEGV
 signal:
 .RS 4
-.TP 15
+.TP
 .B SEGV_MAPERR
-address not mapped to object
+Address not mapped to object.
 .TP
 .B SEGV_ACCERR
-invalid permissions for mapped object
+Invalid permissions for mapped object.
 .RE
 .PP
 The following values can be placed in
@@ -567,15 +624,15 @@ for a
 .B SIGBUS
 signal:
 .RS 4
-.TP 15
+.TP
 .B BUS_ADRALN
-invalid address alignment
+Invalid address alignment.
 .TP
 .B BUS_ADRERR
-nonexistent physical address
+Nonexistent physical address.
 .TP
 .B BUS_OBJERR
-object-specific hardware error
+Object-specific hardware error.
 .TP
 .BR BUS_MCEERR_AR " (since Linux 2.6.32)"
 Hardware memory error consumed on a machine check; action required.
@@ -590,18 +647,18 @@ for a
 .B SIGTRAP
 signal:
 .RS 4
-.TP 15
+.TP
 .B TRAP_BRKPT
-process breakpoint
+Process breakpoint.
 .TP
 .B TRAP_TRACE
-process trace trap
+Process trace trap.
 .TP
 .BR TRAP_BRANCH " (since Linux 2.4)"
-process taken branch trap
+Process taken branch trap.
 .TP
 .BR TRAP_HWBKPT " (since Linux 2.4)"
-hardware breakpoint/watchpoint
+Hardware breakpoint/watchpoint.
 .RE
 .PP
 The following values can be placed in
@@ -610,24 +667,24 @@ for a
 .B SIGCHLD
 signal:
 .RS 4
-.TP 15
+.TP
 .B CLD_EXITED
-child has exited
+Child has exited.
 .TP
 .B CLD_KILLED
-child was killed
+Child was killed.
 .TP
 .B CLD_DUMPED
-child terminated abnormally
+Child terminated abnormally.
 .TP
 .B CLD_TRAPPED
-traced child has trapped
+Traced child has trapped.
 .TP
 .B CLD_STOPPED
-child has stopped
+Child has stopped.
 .TP
-.B CLD_CONTINUED
-stopped child has continued (since Linux 2.6.9)
+.BR CLD_CONTINUED " (since Linux 2.6.9)"
+Stopped child has continued.
 .RE
 .PP
 The following values can be placed in
@@ -636,28 +693,43 @@ for a
 .BR SIGIO / SIGPOLL
 signal:
 .RS 4
-.TP 15
+.TP
 .B POLL_IN
-data input available
+Data input available.
 .TP
 .B POLL_OUT
-output buffers available
+Output buffers available.
 .TP
 .B POLL_MSG
-input message available
+Input message available.
 .TP
 .B POLL_ERR
-I/O error
+I/O error.
 .TP
 .B POLL_PRI
-high priority input available
+High priority input available.
 .TP
 .B POLL_HUP
-device disconnected
+Device disconnected.
+.RE
+.PP
+The following value can be placed in
+.I si_code
+for a
+.BR SIGSYS
+signal:
+.RS 4
+.TP
+.BR SYS_SECCOMP " (since Linux 3.5)"
+Triggered by a
+.BR seccomp (2)
+filter rule.
 .RE
-.SH "RETURN VALUE"
+.SH RETURN VALUE
 .BR sigaction ()
-returns 0 on success and \-1 on error.
+returns 0 on success; on error, \-1 is returned, and
+.I errno
+is set to indicate the error.
 .SH ERRORS
 .TP
 .B EFAULT
@@ -670,7 +742,7 @@ This will also be generated if an attempt
 is made to change the action for
 .BR SIGKILL " or " SIGSTOP ", "
 which cannot be caught or ignored.
-.SH "CONFORMING TO"
+.SH CONFORMING TO
 POSIX.1-2001, SVr4.
 .\" SVr4 does not document the EINTR condition.
 .SH NOTES
@@ -708,7 +780,7 @@ POSIX.1-2001 allows this possibility, so that ignoring
 .B SIGCHLD
 can be used to prevent the creation of zombies (see
 .BR wait (2)).
-Nevertheless, the historical BSD and System V behaviors for ignoring
+Nevertheless, the historical BSD and System\ V behaviors for ignoring
 .B SIGCHLD
 differ, so that the only completely portable method of ensuring that
 terminated children do not become zombies is to catch the
@@ -717,7 +789,7 @@ signal and perform a
 .BR wait (2)
 or similar.
 .PP
-POSIX.1-1990 only specified
+POSIX.1-1990 specified only
 .BR SA_NOCLDSTOP .
 POSIX.1-2001 added
 .BR SA_NOCLDWAIT ,
@@ -772,7 +844,7 @@ namely by using a
 .I sa_handler
 with second argument of type
 .IR "struct sigcontext".
-See the relevant kernel sources for details.
+See the relevant Linux kernel sources for details.
 This use is obsolete now.
 .SH BUGS
 In kernels up to and including 2.6.13, specifying
@@ -786,15 +858,18 @@ This bug was fixed in kernel 2.6.14.
 .SH EXAMPLE
 See
 .BR mprotect (2).
-.SH "SEE ALSO"
+.SH SEE ALSO
 .BR kill (1),
 .BR kill (2),
 .BR killpg (2),
 .BR pause (2),
+.BR restart_syscall (2),
+.BR seccomp (2)
 .BR sigaltstack (2),
 .BR signal (2),
 .BR signalfd (2),
 .BR sigpending (2),
+.BR sigreturn (2),
 .BR sigprocmask (2),
 .BR sigsuspend (2),
 .BR wait (2),
@@ -805,3 +880,12 @@ See
 .BR sigvec (3),
 .BR core (5),
 .BR signal (7)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.