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 librararies 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 static char sccsid[] = "@(#)issignals.c 1.7 89/08/30 Copyr 1988 Sun Micro";
32 * Copyright (c) 1988 by Sun Microsystems, Inc.
39 * Signal masking functions
43 #include "isam_impl.h"
47 * _issignal_mask() is called at the beginning of each ISAM update operation
48 * to mask signals for the duration of the operation. _issignals_unmask()
49 * is called at the end of the operation to restore the original signal
52 * _issignals_cntl() enables/disables this signal masking facility.
53 * (the default is "mask the signals").
55 * The variable already_masked is used to provide more robustness: it
56 * will prevent permanent signal masking due to bugs in the ISAM package.
57 * The permanent masking of signals would happen if _issignals_mask()
58 * were called twice in a row.
62 static int do_mask = 1; /* default value */
63 static int already_masked;
64 static sigset_t oldmask;
65 static sigset_t allsignals;
69 int opt; /* 1 will enable masking */
70 /* 0 will disable masking */
72 int oldmask = do_mask;
74 do_mask = opt ? 1 : 0;
81 if (do_mask && !already_masked) {
82 (void) sigfillset(&allsignals);
83 (void) sigdelset(&allsignals, SIGTRAP);
84 (void) sigdelset(&allsignals, SIGSEGV);
85 (void) sigdelset(&allsignals, SIGILL);
86 (void) sigdelset(&allsignals, SIGBUS);
87 (void) sigprocmask(SIG_SETMASK, &allsignals, &oldmask);
95 (void)sigprocmask(SIG_SETMASK, &oldmask, NULL);