Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/bsd_signal.html
2024-02-19 00:21:47 -05:00

165 lines
5.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>bsd_signal</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="bsd_signal"></a> <a name="tag_03_40"></a><!-- bsd_signal -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_40_01"></a>NAME</h4>
<blockquote>bsd_signal - simplified signal facilities</blockquote>
<h4><a name="tag_03_40_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<div class="box"><code><tt><sup>[<a href="javascript:open_code('OB XSI')">OB XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> #include &lt;<a href="../basedefs/signal.h.html">signal.h</a>&gt;<br>
<br>
void (*bsd_signal(int</tt> <i>sig</i><tt>, void (*</tt><i>func</i><tt>)(int)))(int); <img src="../images/opt-end.gif" alt=
"[Option End]" border="0"></tt></code></div>
<tt><br>
</tt></blockquote>
<h4><a name="tag_03_40_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>bsd_signal</i>() function provides a partially compatible interface for programs written to historical system interfaces
(see APPLICATION USAGE).</p>
<p>The function call <i>bsd_signal</i>(<i>sig</i>, <i>func</i>) shall be equivalent to the following:</p>
<pre>
<tt>void (*bsd_signal(int sig, void (*func)(int)))(int)
{
struct sigaction act, oact;
<br>
act.sa_handler =</tt> <i>func</i><tt>;
act.sa_flags = SA_RESTART;
sigemptyset(&amp;act.sa_mask);
sigaddset(&amp;act.sa_mask,</tt> <i>sig</i><tt>);
if (sigaction(</tt><i>sig</i><tt>, &amp;act, &amp;oact) == -1)
return(SIG_ERR);
return(oact.sa_handler);
}
</tt>
</pre>
<p>The handler function should be declared:</p>
<pre>
<tt>void handler(int</tt> <i>sig</i><tt>);
</tt>
</pre>
<p>where <i>sig</i> is the signal number. The behavior is undefined if <i>func</i> is a function that takes more than one argument,
or an argument of a different type.</p>
</blockquote>
<h4><a name="tag_03_40_04"></a>RETURN VALUE</h4>
<blockquote>
<p>Upon successful completion, <i>bsd_signal</i>() shall return the previous action for <i>sig</i>. Otherwise, SIG_ERR shall be
returned and <i>errno</i> shall be set to indicate the error.</p>
</blockquote>
<h4><a name="tag_03_40_05"></a>ERRORS</h4>
<blockquote>
<p>Refer to <a href="sigaction.html"><i>sigaction</i>()</a> .</p>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_40_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_40_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>This function is a direct replacement for the BSD <a href="../functions/signal.html"><i>signal</i>()</a> function for simple
applications that are installing a single-argument signal handler function. If a BSD signal handler function is being installed
that expects more than one argument, the application has to be modified to use <a href=
"../functions/sigaction.html"><i>sigaction</i>()</a>. The <i>bsd_signal</i>() function differs from <a href=
"../functions/signal.html"><i>signal</i>()</a> in that the SA_RESTART flag is set and the SA_RESETHAND is clear when
<i>bsd_signal</i>() is used. The state of these flags is not specified for <a href=
"../functions/signal.html"><i>signal</i>()</a>.</p>
<p>It is recommended that new applications use the <a href="../functions/sigaction.html"><i>sigaction</i>()</a> function.</p>
</blockquote>
<h4><a name="tag_03_40_08"></a>RATIONALE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_40_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_40_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="sigaction.html"><i>sigaction</i>()</a> , <a href="sigaddset.html"><i>sigaddset</i>()</a> , <a href=
"sigemptyset.html"><i>sigemptyset</i>()</a> , <a href="signal.html"><i>signal</i>()</a> , the Base Definitions volume of
IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_40_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 4, Version 2.</p>
</blockquote>
<h4><a name="tag_03_40_12"></a>Issue 5</h4>
<blockquote>
<p>Moved from X/OPEN UNIX extension to BASE.</p>
</blockquote>
<h4><a name="tag_03_40_13"></a>Issue 6</h4>
<blockquote>
<p>This function is marked obsolescent.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>