1BSD_SIGNAL(3P) POSIX Programmer's Manual BSD_SIGNAL(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 bsd_signal - simplified signal facilities
13
15 #include <signal.h>
16
17 void (*bsd_signal(int sig, void (*func)(int)))(int);
18
19
21 The bsd_signal() function provides a partially compatible interface for
22 programs written to historical system interfaces (see APPLICATION
23 USAGE).
24
25 The function call bsd_signal(sig, func) shall be equivalent to the fol‐
26 lowing:
27
28
29 void (*bsd_signal(int sig, void (*func)(int)))(int)
30 {
31 struct sigaction act, oact;
32
33
34 act.sa_handler = func;
35 act.sa_flags = SA_RESTART;
36
37 sigemptyset(&act.sa_mask);
38 sigaddset(&act.sa_mask, sig);
39 if (sigaction(sig, &act, &oact) == -1)
40 return(SIG_ERR);
41
42 return(oact.sa_handler);
43 }
44
45 The handler function should be declared:
46
47
48 void handler(int sig);
49
50 where sig is the signal number. The behavior is undefined if func is a
51 function that takes more than one argument, or an argument of a differ‐
52 ent type.
53
55 Upon successful completion, bsd_signal() shall return the previous
56 action for sig. Otherwise, SIG_ERR shall be returned and errno shall be
57 set to indicate the error.
58
60 Refer to sigaction().
61
62 The following sections are informative.
63
65 None.
66
68 This function is a direct replacement for the BSD signal() function for
69 simple applications that are installing a single-argument signal han‐
70 dler function. If a BSD signal handler function is being installed that
71 expects more than one argument, the application has to be modified to
72 use sigaction(). The bsd_signal() function differs from signal() in
73 that the SA_RESTART flag is set and the SA_RESETHAND is clear when
74 bsd_signal() is used. The state of these flags is not specified for
75 signal().
76
77 It is recommended that new applications use the sigaction() function.
78
80 None.
81
83 None.
84
86 sigaction(), sigaddset(), sigemptyset(), signal(), the Base Definitions
87 volume of IEEE Std 1003.1-2001, <signal.h>
88
90 Portions of this text are reprinted and reproduced in electronic form
91 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
92 -- Portable Operating System Interface (POSIX), The Open Group Base
93 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
94 Electrical and Electronics Engineers, Inc and The Open Group. In the
95 event of any discrepancy between this version and the original IEEE and
96 The Open Group Standard, the original IEEE and The Open Group Standard
97 is the referee document. The original Standard can be obtained online
98 at http://www.opengroup.org/unix/online.html .
99
100
101
102IEEE/The Open Group 2003 BSD_SIGNAL(3P)