.\" .\" 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 .\" http://www.opengroup.org/bookstore/. .\" .\" 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 SunOS 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. .\" .\" This notice shall appear on any product containing this material. .\" .\" 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. .\" .\" 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. .\" .\" 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] .\" .\" .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved. .\" Portions Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved. .\" .TH BSD_SIGNAL 3C "May 13, 2017" .SH NAME bsd_signal \- simplified signal facilities .SH SYNOPSIS .LP .nf #include \fBvoid\fR (\fB*bsd_signal(int\fR \fIsig\fR, \fBvoid\fR (*\fIfunc\fR)(\fBint\fR)))(\fBint\fR); .fi .SH DESCRIPTION .LP The \fBbsd_signal()\fR function provides a partially compatible interface for programs written to historical system interfaces (see \fBUSAGE\fR below). .sp .LP The function call \fBbsd_signal\fR(\fIsig\fR, \fIfunc\fR) has an effect as if implemented as: .sp .in +2 .nf void (*bsd_signal(int sig, void (*func)\|(int)))\|(int) { struct sigaction act, oact; act.sa_handler = \fIfunc\fR; act.sa_flags = SA_RESTART; sigemptyset(&act.sa_mask); sigaddset(&act.sa_mask, \fIsig\fR); if (sigaction(\fIsig\fR, &act, &oact) == \(mi1) return(\fBSIG_ERR\fR); return(oact.sa_handler); } .fi .in -2 .sp .LP The handler function should be declared: .sp .in +2 .nf void handler(int \fIsig\fR); .fi .in -2 .sp .LP where \fIsig\fR is the signal number. The behavior is undefined if \fIfunc\fR is a function that takes more than one argument, or an argument of a different type. .SH RETURN VALUES .LP Upon successful completion, \fBbsd_signal()\fR returns the previous action for \fIsig\fR. Otherwise, \fBSIG_ERR\fR is returned and \fBerrno\fR is set to indicate the error. .SH ERRORS .LP Refer to \fBsigaction\fR(2). .SH USAGE .LP This function is a direct replacement for the \fBBSD\fR \fBsignal()\fR function for simple applications that are installing a single-argument signal handler function. If a \fBBSD\fR signal handler function is being installed that expects more than one argument, the application has to be modified to use \fBsigaction\fR(2). The \fBbsd_signal()\fR function differs from the \fBBSD\fR \fBsignal()\fR in that the \fBSA_RESTART\fR flag is set and the \fBSA_RESETHAND\fR will be clear when \fBbsd_signal()\fR is used. The state of these flags is not specified for the \fBBSD\fR \fBsignal()\fR. .SH ATTRIBUTES .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Standard .TE .SH SEE ALSO .LP .BR sigaction (2), .BR sigaddset (3C), .BR sigemptyset (3C), .BR attributes (7), .BR standards (7)