1 .\"  Copyright (c) 1992, X/Open Company Limited All Rights Reserved  Portions Copyright (c) 2002, Sun Microsystems, Inc.  All Rights Reserved
   2 .\" 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
   3 .\" http://www.opengroup.org/bookstore/.
   4 .\" 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.
   5 .\"  This notice shall appear on any product containing this material.
   6 .\" 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.
   7 .\" 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.
   8 .\" 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]
   9 .Dd "Jul 19, 2014"
  10 .Dt BSD_SIGNAL 3C
  11 .Os
  12 .Sh NAME
  13 .Nm bsd_signal
  14 .Nd simplified signal facilities
  15 .Sh SYNOPSIS
  16 .In signal.h
  17 .Ft void
  18 .Fn \*(lp*bsd_signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint"
  19 .\" \fBvoid\fR (\fB*bsd_signal(int\fR \fIsig\fR, \fBvoid\fR (*\fIfunc\fR)(\fBint\fR)))(\fBint\fR);
  20 .Sh DESCRIPTION
  21 The
  22 .Fn bsd_signal
  23 function provides a partially compatible interface for
  24 programs written to historical system interfaces (see
  25 .Sx USAGE
  26 below).
  27 .Lp
  28 The function call
  29 .Fn bsd_signal sig func
  30 has an effect as if implemented as:
  31 .Bd -literal -offset indent
  32 void (*bsd_signal(int sig, void (*func)\|(int)))\|(int)
  33 {
  34      struct sigaction act, oact;
  35 
  36      act.sa_handler = func;
  37      act.sa_flags = SA_RESTART;
  38      sigemptyset(&act.sa_mask);
  39      sigaddset(&act.sa_mask, sig);
  40      if (sigaction(sig, &act, &oact) == \(mi1)
  41           return(SIG_ERR);
  42      return(oact.sa_handler);
  43 }
  44 .Ed
  45 .Lp
  46 The handler function should be declared:
  47 .Lp
  48 .Dl Ft void Fn handler "int sig" ;
  49 .Lp
  50 where
  51 .Fa sig
  52 is the signal number.  The behavior is undefined if
  53 .Fa func
  54 is a function that takes more than one argument, or an argument of a different
  55 type.
  56 .Sh RETURN VALUES
  57 Upon successful completion,
  58 .Fn bsd_signal
  59 returns the previous action for
  60 .Fa sig .
  61 Otherwise,
  62 .Dv SIG_ERR
  63 is returned and
  64 .Va errno
  65 is set to indicate the error.
  66 .Sh ERRORS
  67 Refer to
  68 .Xr sigaction 2 .
  69 .Sh USAGE
  70 This function is a direct replacement for the
  71 .Bx
  72 .Fn signal
  73 function for simple applications that are installing a single-argument signal
  74 handler function.  If a
  75 .Bx
  76 signal handler function is being installed
  77 that expects more than one argument, the application has to be modified to use
  78 .Xr sigaction 2 .
  79 .Lp
  80 Portable applications should use
  81 .Xr sigaction 2
  82 instead of this function.
  83 .Sh INTERFACE STABILITY
  84 .Sy Obsolete Standard .
  85 .Sh SEE ALSO
  86 .Xr sigaction 2 ,
  87 .Xr sigaddset 3C ,
  88 .Xr sigemptyset 3C ,
  89 .Xr standards 5
  90 .Sh STANDARDS
  91 The
  92 .Fn bsd_signal
  93 function was added in
  94 .St -xpg4.2 .
  95 It was subsequently obsoleted in
  96 .St -p1003.1-2001
  97 and removed from
  98 .St -p1003.1-2008 .