1 '\" te 2 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved 3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at 4 .\" http://www.opengroup.org/bookstore/. 5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions 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. 6 .\" This notice shall appear on any product containing this material. 7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. 8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. 9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] 10 .TH BSD_SIGNAL 3C "Jul 24, 2002" 11 .SH NAME 12 bsd_signal \- simplified signal facilities 13 .SH SYNOPSIS 14 .LP 15 .nf 16 #include <signal.h> 17 18 \fBvoid\fR (\fB*bsd_signal(int\fR \fIsig\fR, \fBvoid\fR (*\fIfunc\fR)(\fBint\fR)))(\fBint\fR); 19 .fi 20 21 .SH DESCRIPTION 22 .sp 23 .LP 24 The \fBbsd_signal()\fR function provides a partially compatible interface for 25 programs written to historical system interfaces (see \fBUSAGE\fR below). 26 .sp 27 .LP 28 The function call \fBbsd_signal\fR(\fIsig\fR, \fIfunc\fR) has an effect as if 29 implemented as: 30 .sp 31 .in +2 32 .nf 33 void (*bsd_signal(int sig, void (*func)\|(int)))\|(int) 34 { 35 struct sigaction act, oact; 36 37 act.sa_handler = \fIfunc\fR; 38 act.sa_flags = SA_RESTART; 39 sigemptyset(&act.sa_mask); 40 sigaddset(&act.sa_mask, \fIsig\fR); 41 if (sigaction(\fIsig\fR, &act, &oact) == \(mi1) 42 return(\fBSIG_ERR\fR); 43 return(oact.sa_handler); 44 } 45 .fi 46 .in -2 47 48 .sp 49 .LP 50 The handler function should be declared: 51 .sp 52 .in +2 53 .nf 54 void handler(int \fIsig\fR); 55 .fi 56 .in -2 57 58 .sp 59 .LP 60 where \fIsig\fR is the signal number. The behavior is undefined if \fIfunc\fR 61 is a function that takes more than one argument, or an argument of a different 62 type. 63 .SH RETURN VALUES 64 .sp 65 .LP 66 Upon successful completion, \fBbsd_signal()\fR returns the previous action for 67 \fIsig\fR. Otherwise, \fBSIG_ERR\fR is returned and \fBerrno\fR is set to 68 indicate the error. 69 .SH ERRORS 70 .sp 71 .LP 72 Refer to \fBsigaction\fR(2). 73 .SH USAGE 74 .sp 75 .LP 76 This function is a direct replacement for the \fBBSD\fR \fBsignal\fR(3UCB) 77 function for simple applications that are installing a single-argument signal 78 handler function. If a \fBBSD\fR signal handler function is being installed 79 that expects more than one argument, the application has to be modified to use 80 \fBsigaction\fR(2). The \fBbsd_signal()\fR function differs from 81 \fBsignal\fR(3UCB) in that the \fBSA_RESTART\fR flag is set and the 82 \fBSA_RESETHAND\fR will be clear when \fBbsd_signal()\fR is used. The state of 83 these flags is not specified for \fBsignal\fR(3UCB). 84 .SH ATTRIBUTES 85 .sp 86 .LP 87 See \fBattributes\fR(5) for descriptions of the following attributes: 88 .sp 89 90 .sp 91 .TS 92 box; 93 c | c 94 l | l . 95 ATTRIBUTE TYPE ATTRIBUTE VALUE 96 _ 97 Interface Stability Standard 98 .TE 99 100 .SH SEE ALSO 101 .sp 102 .LP 103 \fBsigaction\fR(2), \fBsigaddset\fR(3C), \fBsigemptyset\fR(3C), 104 \fBsignal\fR(3UCB), \fBattributes\fR(5), \fBstandards\fR(5)