1BSD_SIGNAL(P)              POSIX Programmer's Manual             BSD_SIGNAL(P)
2
3
4

NAME

6       bsd_signal - simplified signal facilities
7

SYNOPSIS

9       #include <signal.h>
10
11       void (*bsd_signal(int sig, void (*func)(int)))(int);
12
13

DESCRIPTION

15       The bsd_signal() function provides a partially compatible interface for
16       programs written  to  historical  system  interfaces  (see  APPLICATION
17       USAGE).
18
19       The function call bsd_signal(sig, func) shall be equivalent to the fol‐
20       lowing:
21
22
23              void (*bsd_signal(int sig, void (*func)(int)))(int)
24              {
25                  struct sigaction act, oact;
26
27
28                  act.sa_handler = func;
29                  act.sa_flags = SA_RESTART;
30
31                  sigemptyset(&act.sa_mask);
32                  sigaddset(&act.sa_mask, sig);
33                  if (sigaction(sig, &act, &oact) == -1)
34                      return(SIG_ERR);
35
36                  return(oact.sa_handler);
37              }
38
39       The handler function should be declared:
40
41
42              void handler(int sig);
43
44       where sig is the signal number. The behavior is undefined if func is  a
45       function that takes more than one argument, or an argument of a differ‐
46       ent type.
47

RETURN VALUE

49       Upon successful completion,  bsd_signal()  shall  return  the  previous
50       action for sig. Otherwise, SIG_ERR shall be returned and errno shall be
51       set to indicate the error.
52

ERRORS

54       Refer to sigaction() .
55
56       The following sections are informative.
57

EXAMPLES

59       None.
60

APPLICATION USAGE

62       This function is a direct replacement for the BSD signal() function for
63       simple  applications  that are installing a single-argument signal han‐
64       dler function. If a BSD signal handler function is being installed that
65       expects  more  than one argument, the application has to be modified to
66       use sigaction(). The bsd_signal() function  differs  from  signal()  in
67       that  the  SA_RESTART  flag  is  set and the SA_RESETHAND is clear when
68       bsd_signal() is used. The state of these flags  is  not  specified  for
69       signal().
70
71       It is recommended that new applications use the sigaction() function.
72

RATIONALE

74       None.
75

FUTURE DIRECTIONS

77       None.
78

SEE ALSO

80       sigaction() , sigaddset() , sigemptyset() , signal() , the Base Defini‐
81       tions volume of IEEE Std 1003.1-2001, <signal.h>
82
84       Portions of this text are reprinted and reproduced in  electronic  form
85       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
86       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
87       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
88       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
89       event of any discrepancy between this version and the original IEEE and
90       The Open Group Standard, the original IEEE and The Open Group  Standard
91       is  the  referee document. The original Standard can be obtained online
92       at http://www.opengroup.org/unix/online.html .
93
94
95
96IEEE/The Open Group                  2003                        BSD_SIGNAL(P)
Impressum