1 .\" Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3 .\" @APPLE_LICENSE_HEADER_START@
5 .\" The contents of this file constitute Original Code as defined in and
6 .\" are subject to the Apple Public Source License Version 1.1 (the
7 .\" "License"). You may not use this file except in compliance with the
8 .\" License. Please obtain a copy of the License at
9 .\" http://www.apple.com/publicsource and read it before using this file.
11 .\" This Original Code and all software distributed under the License are
12 .\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
13 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
14 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
15 .\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
16 .\" License for the specific language governing rights and limitations
17 .\" under the License.
19 .\" @APPLE_LICENSE_HEADER_END@
26 .Nd simplified signal facilities
29 .\" The following is Quite Ugly, but syntactically correct. Don't try to
32 .Fn bsd_signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint"
34 or in an equivalent but easier to read typedef'd version:
35 .Ft typedef "void \*(lp*sig_t\*(rp \*(lpint\*(rp" ;
37 .Fn bsd_signal "int sig" "sig_t func"
41 function provides a partially compatible interface for programs written
42 to historical system interfaces (see USAGE below).
45 .Fn bsd_signal sig func
46 has the effect as if implemented as:
47 .Bd -literal -offset indent
48 void (*bsd_signal(int sig, void (*func)(int)))(int)
50 struct sigaction act, oact;
52 act.sa_handler = func;
53 act.sa_flags = SA_RESTART;
54 sigemptyset(&act.sa_mask);
55 sigaddset(&act.sa_mask, sig);
56 if (sigaction(sig, &act, &oact) == -1)
58 return(oact.sa_handler);
62 The handler function should be declared:
64 .D1 Fn "void func" "int sig"
69 The behavior is undefined if
71 is a function that takes more than one argument, or an argument of a
74 Upon successful completion,
76 returns the previous action for
82 is set to indicate the error.
87 This function is a direct replacement for the
90 function for simple applications that are installing a single-argument signal
94 signal handler function is being installed that expects more than one
95 argument, the application has to be modified to use
108 The state of these flags is not specified for