]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/sigaction.c
ncurses 4.1
[ncurses.git] / ncurses / sigaction.c
1
2 /***************************************************************************
3 *                            COPYRIGHT NOTICE                              *
4 ****************************************************************************
5 *                ncurses is copyright (C) 1992-1995                        *
6 *                          Zeyd M. Ben-Halim                               *
7 *                          zmbenhal@netcom.com                             *
8 *                          Eric S. Raymond                                 *
9 *                          esr@snark.thyrsus.com                           *
10 *                                                                          *
11 *        Permission is hereby granted to reproduce and distribute ncurses  *
12 *        by any means and for any fee, whether alone or as part of a       *
13 *        larger distribution, in source or in binary form, PROVIDED        *
14 *        this notice is included with any such distribution, and is not    *
15 *        removed from any of its header files. Mention of ncurses in any   *
16 *        applications linked with it is highly appreciated.                *
17 *                                                                          *
18 *        ncurses comes AS IS with no warranty, implied or expressed.       *
19 *                                                                          *
20 ***************************************************************************/
21
22 #include <curses.priv.h>
23
24 /* This file provides sigaction() emulation using sigvec() */
25 /* Use only if this is non POSIX system */
26
27 #if !HAVE_SIGACTION
28 #include <signal.h>
29 #include <SigAction.h>
30
31 MODULE_ID("$Id: sigaction.c,v 1.6 1996/07/31 00:15:36 tom Exp $")
32
33 int
34 sigaction (int sig, sigaction_t * sigact, sigaction_t * osigact)
35 {
36   return sigvec(sig, sigact, osigact);
37 }
38
39 int
40 sigemptyset (sigset_t * mask)
41 {
42   *mask = 0;
43   return 0;
44 }
45
46 int
47 sigprocmask (int mode, sigset_t * mask, sigset_t * omask)
48    {
49    sigset_t current = sigsetmask(0);
50
51    if (omask) *omask = current;
52
53    if (mode==SIG_BLOCK)
54       current |= *mask;
55    else if (mode==SIG_UNBLOCK)
56       current &= ~*mask;
57    else if (mode==SIG_SETMASK)
58       current = *mask;
59
60    sigsetmask(current);
61    return 0;
62    }
63
64 int
65 sigsuspend (sigset_t * mask)
66 {
67   return sigpause (*mask);
68 }
69
70 int
71 sigdelset (sigset_t * mask, int sig)
72 {
73   *mask &= ~sigmask (sig);
74   return 0;
75 }
76
77 int
78 sigaddset (sigset_t * mask, int sig)
79 {
80   *mask |= sigmask (sig);
81   return 0;
82 }
83 #else
84 extern void _nc_sigaction(void);        /* quiet's gcc warning */
85 void _nc_sigaction(void) { } /* nonempty for strict ANSI compilers */
86 #endif