{"id":4773,"date":"2022-12-20T18:36:52","date_gmt":"2022-12-20T21:36:52","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/signal-man3p\/"},"modified":"2022-12-20T18:36:52","modified_gmt":"2022-12-20T21:36:52","slug":"signal-man3p","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/signal-man3p\/","title":{"rendered":"SIGNAL (man3p)"},"content":{"rendered":"<h1 align=\"center\">SIGNAL<\/h1>\n<p> <a href=\"#PROLOG\">PROLOG<\/a><br \/> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#ERRORS\">ERRORS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#APPLICATION USAGE\">APPLICATION USAGE<\/a><br \/> <a href=\"#RATIONALE\">RATIONALE<\/a><br \/> <a href=\"#FUTURE DIRECTIONS\">FUTURE DIRECTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>PROLOG <a name=\"PROLOG\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This manual page is part of the POSIX Programmer\u2019s Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">signal \u2014 signal management<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">#include <signal.h><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">void (*signal(int <i>sig<\/i>, void (*<i>func<\/i>)(int)))(int);<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The functionality described on this reference page is aligned with the ISO\u00a0C standard. Any conflict between the requirements described here and the ISO\u00a0C standard is unintentional. This volume of POSIX.1-2017 defers to the ISO\u00a0C standard.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>signal<\/i>() function chooses one of three ways in which receipt of the signal number <i>sig<\/i> is to be subsequently handled. If the value of <i>func<\/i> is SIG_DFL, default handling for that signal shall occur. If the value of <i>func<\/i> is SIG_IGN, the signal shall be ignored. Otherwise, the application shall ensure that <i>func<\/i> points to a function to be called when that signal occurs. An invocation of such a function because of a signal, or (recursively) of any further functions called by that invocation (other than functions in the standard library), is called a \u2018\u2018signal handler\u2019\u2019.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When a signal occurs, and <i>func<\/i> points to a function, it is implementation-defined whether the equivalent of a:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">signal(<i>sig<\/i>, SIG_DFL);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">is executed or the implementation prevents some implementation-defined set of signals (at least including <i>sig<\/i>) from occurring until the current signal handling has completed. (If the value of <i>sig<\/i> is SIGILL, the implementation may alternatively define that no action is taken.) Next the equivalent of:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">(*func)(sig);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">is executed. If and when the function returns, if the value of <i>sig<\/i> was SIGFPE, SIGILL, or SIGSEGV or any other implementation-defined value corresponding to a computational exception, the behavior is undefined. Otherwise, the program shall resume execution at the point it was interrupted. The ISO\u00a0C standard places a restriction on applications relating to the use of <i>raise<\/i>() from signal handlers. This restriction does not apply to POSIX applications, as POSIX.1-2008 requires <i>raise<\/i>() to be async-signal-safe (see <i>Section 2.4.3<\/i>, <i>Signal Actions<\/i>).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the process is multi-threaded, or if the process is single-threaded and a signal handler is executed other than as the result of:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>The process calling <i>abort<\/i>(), <i>raise<\/i>(), <i>kill<\/i>(), <i>pthread_kill<\/i>(), or <i>sigqueue<\/i>() to generate a signal that is not blocked<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>A pending signal being unblocked and being delivered before the call that unblocked it returns<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">the behavior is undefined if the signal handler refers to any object other than <i>errno<\/i> with static storage duration other than by assigning a value to an object declared as <b>volatile sig_atomic_t<\/b>, or if the signal handler calls any function defined in this standard other than one of the functions listed in <i>Section 2.4<\/i>, <i>Signal Concepts<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">At program start-up, the equivalent of:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">signal(<i>sig<\/i>, SIG_IGN);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">is executed for some signals, and the equivalent of:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">signal(<i>sig<\/i>, SIG_DFL);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">is executed for all other signals (see <i>exec<\/i>).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>signal<\/i>() function shall not change the setting of <i>errno<\/i> if successful.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">If the request can be honored, <i>signal<\/i>() shall return the value of <i>func<\/i> for the most recent call to <i>signal<\/i>() for the specified signal <i>sig<\/i>. Otherwise, SIG_ERR shall be returned and a positive value shall be stored in <i>errno<\/i>.<\/p>\n<h2>ERRORS <a name=\"ERRORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>signal<\/i>() function shall fail if:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\"><b>EINVAL<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">The <i>sig<\/i> argument is not a valid signal number or an attempt is made to catch a signal that cannot be caught or ignore a signal that cannot be ignored.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>signal<\/i>() function may fail if:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\"><b>EINVAL<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">An attempt was made to set the action to SIG_DFL for a signal that cannot be caught or ignored (or both).<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>The following sections are informative.<\/i><\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>APPLICATION USAGE <a name=\"APPLICATION USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>sigaction<\/i>() function provides a more comprehensive and reliable mechanism for controlling signals; new applications should use <i>sigaction<\/i>() rather than <i>signal<\/i>().<\/p>\n<h2>RATIONALE <a name=\"RATIONALE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>FUTURE DIRECTIONS <a name=\"FUTURE DIRECTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>Section 2.4<\/i>, <i>Signal Concepts<\/i>, <i>exec<\/i>, <i>pause<\/i>(), <i>raise<\/i>(), <i>sigaction<\/i>(), <i>sigsuspend<\/i>(), <i>waitid<\/i>()<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The Base Definitions volume of POSIX.1-2017, <b><signal.h><\/b><\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology &#8212; Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http:\/\/www.opengroup.org\/unix\/online.html .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https:\/\/www.kernel.org\/doc\/man-pages\/reporting_bugs.html .<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  signal \u2014 signal management <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3779,1],"tags":[1594,1023],"class_list":["post-4773","post","type-post","status-publish","format-standard","hentry","category-3pm-perl-llamadas-de-bibliotecas","category-sin-categoria","tag-man3p","tag-signal"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=4773"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4773\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}