2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
24 /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
25 /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
26 /*%% (c) Copyright 1993, 1994 Novell, Inc. */
27 /*%% $XConsortium: issignals.c /main/3 1995/10/23 11:44:41 rswiston $ */
29 * Copyright (c) 1988 by Sun Microsystems, Inc.
36 * Signal masking functions
40 #include "isam_impl.h"
44 * _issignal_mask() is called at the beginning of each ISAM update operation
45 * to mask signals for the duration of the operation. _issignals_unmask()
46 * is called at the end of the operation to restore the original signal
49 * _issignals_cntl() enables/disables this signal masking facility.
50 * (the default is "mask the signals").
52 * The variable already_masked is used to provide more robustness: it
53 * will prevent permanent signal masking due to bugs in the ISAM package.
54 * The permanent masking of signals would happen if _issignals_mask()
55 * were called twice in a row.
59 static int do_mask = 1; /* default value */
60 static int already_masked;
61 static sigset_t oldmask;
62 static sigset_t allsignals;
65 /* opt, 1 will enable masking, 0 will disable masking */
66 int _issignals_cntl(int opt)
68 int oldmask = do_mask;
70 do_mask = opt ? 1 : 0;
78 if (do_mask && !already_masked) {
79 (void) sigfillset(&allsignals);
80 (void) sigdelset(&allsignals, SIGTRAP);
81 (void) sigdelset(&allsignals, SIGSEGV);
82 (void) sigdelset(&allsignals, SIGILL);
83 (void) sigdelset(&allsignals, SIGBUS);
84 (void) sigprocmask(SIG_SETMASK, &allsignals, &oldmask);
90 _issignals_unmask(void)
93 (void)sigprocmask(SIG_SETMASK, &oldmask, NULL);