logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

signal.3p (5711B)


  1. '\" et
  2. .TH SIGNAL "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. signal
  12. \(em signal management
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <signal.h>
  17. .P
  18. void (*signal(int \fIsig\fP, void (*\fIfunc\fP)(int)))(int);
  19. .fi
  20. .SH DESCRIPTION
  21. The functionality described on this reference page is aligned with the
  22. ISO\ C standard. Any conflict between the requirements described here and the
  23. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  24. .P
  25. The
  26. \fIsignal\fR()
  27. function chooses one of three ways in which receipt of the signal
  28. number
  29. .IR sig
  30. is to be subsequently handled. If the value of
  31. .IR func
  32. is SIG_DFL, default handling for that signal shall occur.
  33. If the value of
  34. .IR func
  35. is SIG_IGN, the signal shall be ignored.
  36. Otherwise, the application shall ensure that
  37. .IR func
  38. points to a function to be called when that signal occurs. An
  39. invocation of such a function because of a signal, or (recursively) of
  40. any further functions called by that invocation (other than functions
  41. in the standard library), is called a ``signal handler''.
  42. .P
  43. When a signal occurs, and
  44. .IR func
  45. points to a function, it is implementation-defined whether the
  46. equivalent of a:
  47. .sp
  48. .RS 4
  49. .nf
  50. signal(\fIsig\fP, SIG_DFL);
  51. .fi
  52. .P
  53. .RE
  54. .P
  55. is executed or the implementation prevents some implementation-defined
  56. set of signals (at least including
  57. .IR sig )
  58. from occurring until the current signal handling has completed. (If the
  59. value of
  60. .IR sig
  61. is SIGILL, the implementation may alternatively define that no action
  62. is taken.) Next the equivalent of:
  63. .sp
  64. .RS 4
  65. .nf
  66. (*func)(sig);
  67. .fi
  68. .P
  69. .RE
  70. .P
  71. is executed. If and when the function returns, if the value of
  72. .IR sig
  73. was SIGFPE, SIGILL, or SIGSEGV or any other implementation-defined
  74. value corresponding to
  75. a computational exception, the behavior is undefined. Otherwise, the
  76. program shall resume execution at the point it was interrupted. The
  77. ISO\ C standard places a restriction on applications relating to the use of
  78. \fIraise\fR()
  79. from signal handlers.
  80. This restriction does not apply to POSIX applications, as POSIX.1\(hy2008 requires
  81. \fIraise\fR()
  82. to be async-signal-safe (see
  83. .IR "Section 2.4.3" ", " "Signal Actions").
  84. .P
  85. If the process is multi-threaded,
  86. or if the process is single-threaded and a signal handler is
  87. executed other than as the result of:
  88. .IP " *" 4
  89. The process calling
  90. \fIabort\fR(),
  91. \fIraise\fR(),
  92. \fIkill\fR(),
  93. \fIpthread_kill\fR(),
  94. or
  95. \fIsigqueue\fR()
  96. to generate a signal that is not blocked
  97. .IP " *" 4
  98. A pending signal being unblocked and being delivered before the call
  99. that unblocked it returns
  100. .P
  101. the behavior is undefined if the signal handler refers to any object
  102. other than
  103. .IR errno
  104. with static storage duration other than by assigning a value to an
  105. object declared as
  106. .BR "volatile sig_atomic_t" ,
  107. or if the signal handler calls any function defined in this standard
  108. other than
  109. one of the functions listed in
  110. .IR "Section 2.4" ", " "Signal Concepts".
  111. .P
  112. At program start-up, the equivalent of:
  113. .sp
  114. .RS 4
  115. .nf
  116. signal(\fIsig\fP, SIG_IGN);
  117. .fi
  118. .P
  119. .RE
  120. .P
  121. is executed for some signals, and the equivalent of:
  122. .sp
  123. .RS 4
  124. .nf
  125. signal(\fIsig\fP, SIG_DFL);
  126. .fi
  127. .P
  128. .RE
  129. .P
  130. is executed for all other signals
  131. (see
  132. .IR exec ).
  133. .P
  134. The
  135. \fIsignal\fR()
  136. function shall not change the setting of
  137. .IR errno
  138. if successful.
  139. .SH "RETURN VALUE"
  140. If the request can be honored,
  141. \fIsignal\fR()
  142. shall return the value of
  143. .IR func
  144. for the most recent call to
  145. \fIsignal\fR()
  146. for the specified signal
  147. .IR sig .
  148. Otherwise, SIG_ERR shall be returned and a positive value shall
  149. be stored in
  150. .IR errno .
  151. .SH ERRORS
  152. The
  153. \fIsignal\fR()
  154. function shall fail if:
  155. .TP
  156. .BR EINVAL
  157. The
  158. .IR sig
  159. argument is not a valid signal number or an attempt is made to catch a
  160. signal that cannot be caught or ignore a signal that cannot be
  161. ignored.
  162. .P
  163. The
  164. \fIsignal\fR()
  165. function may fail if:
  166. .TP
  167. .BR EINVAL
  168. An attempt was made to set the action to SIG_DFL for a signal that
  169. cannot be caught or ignored (or both).
  170. .LP
  171. .IR "The following sections are informative."
  172. .SH EXAMPLES
  173. None.
  174. .SH "APPLICATION USAGE"
  175. The
  176. \fIsigaction\fR()
  177. function provides a more comprehensive and reliable mechanism for
  178. controlling signals; new applications should use
  179. \fIsigaction\fR()
  180. rather than
  181. \fIsignal\fR().
  182. .SH RATIONALE
  183. None.
  184. .SH "FUTURE DIRECTIONS"
  185. None.
  186. .SH "SEE ALSO"
  187. .IR "Section 2.4" ", " "Signal Concepts",
  188. .IR "\fIexec\fR\^",
  189. .IR "\fIpause\fR\^(\|)",
  190. .IR "\fIraise\fR\^(\|)",
  191. .IR "\fIsigaction\fR\^(\|)",
  192. .IR "\fIsigsuspend\fR\^(\|)",
  193. .IR "\fIwaitid\fR\^(\|)"
  194. .P
  195. The Base Definitions volume of POSIX.1\(hy2017,
  196. .IR "\fB<signal.h>\fP"
  197. .\"
  198. .SH COPYRIGHT
  199. Portions of this text are reprinted and reproduced in electronic form
  200. from IEEE Std 1003.1-2017, Standard for Information Technology
  201. -- Portable Operating System Interface (POSIX), The Open Group Base
  202. Specifications Issue 7, 2018 Edition,
  203. Copyright (C) 2018 by the Institute of
  204. Electrical and Electronics Engineers, Inc and The Open Group.
  205. In the event of any discrepancy between this version and the original IEEE and
  206. The Open Group Standard, the original IEEE and The Open Group Standard
  207. is the referee document. The original Standard can be obtained online at
  208. http://www.opengroup.org/unix/online.html .
  209. .PP
  210. Any typographical or formatting errors that appear
  211. in this page are most likely
  212. to have been introduced during the conversion of the source files to
  213. man page format. To report such errors, see
  214. https://www.kernel.org/doc/man-pages/reporting_bugs.html .