1*0Sstevel@tonic-gate /* $OpenBSD: sigaction.c,v 1.3 1999/06/27 08:14:21 millert Exp $ */ 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate /**************************************************************************** 4*0Sstevel@tonic-gate * Copyright (c) 1998 Free Software Foundation, Inc. * 5*0Sstevel@tonic-gate * * 6*0Sstevel@tonic-gate * Permission is hereby granted, free of charge, to any person obtaining a * 7*0Sstevel@tonic-gate * copy of this software and associated documentation files (the * 8*0Sstevel@tonic-gate * "Software"), to deal in the Software without restriction, including * 9*0Sstevel@tonic-gate * without limitation the rights to use, copy, modify, merge, publish, * 10*0Sstevel@tonic-gate * distribute, distribute with modifications, sublicense, and/or sell * 11*0Sstevel@tonic-gate * copies of the Software, and to permit persons to whom the Software is * 12*0Sstevel@tonic-gate * furnished to do so, subject to the following conditions: * 13*0Sstevel@tonic-gate * * 14*0Sstevel@tonic-gate * The above copyright notice and this permission notice shall be included * 15*0Sstevel@tonic-gate * in all copies or substantial portions of the Software. * 16*0Sstevel@tonic-gate * * 17*0Sstevel@tonic-gate * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 18*0Sstevel@tonic-gate * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 19*0Sstevel@tonic-gate * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 20*0Sstevel@tonic-gate * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 21*0Sstevel@tonic-gate * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 22*0Sstevel@tonic-gate * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 23*0Sstevel@tonic-gate * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 24*0Sstevel@tonic-gate * * 25*0Sstevel@tonic-gate * Except as contained in this notice, the name(s) of the above copyright * 26*0Sstevel@tonic-gate * holders shall not be used in advertising or otherwise to promote the * 27*0Sstevel@tonic-gate * sale, use or other dealings in this Software without prior written * 28*0Sstevel@tonic-gate * authorization. * 29*0Sstevel@tonic-gate ****************************************************************************/ 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate /**************************************************************************** 32*0Sstevel@tonic-gate * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 33*0Sstevel@tonic-gate * and: Eric S. Raymond <esr@snark.thyrsus.com> * 34*0Sstevel@tonic-gate ****************************************************************************/ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include "includes.h" 37*0Sstevel@tonic-gate #include <signal.h> 38*0Sstevel@tonic-gate #include "sigact.h" 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* This file provides sigaction() emulation using sigvec() */ 41*0Sstevel@tonic-gate /* Use only if this is non POSIX system */ 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate #if !HAVE_SIGACTION && HAVE_SIGVEC 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate int 46*0Sstevel@tonic-gate sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact) 47*0Sstevel@tonic-gate { 48*0Sstevel@tonic-gate return sigvec(sig, &(sigact->sv), &(osigact->sv)); 49*0Sstevel@tonic-gate } 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate int 52*0Sstevel@tonic-gate sigemptyset (sigset_t * mask) 53*0Sstevel@tonic-gate { 54*0Sstevel@tonic-gate *mask = 0; 55*0Sstevel@tonic-gate return 0; 56*0Sstevel@tonic-gate } 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate int 59*0Sstevel@tonic-gate sigprocmask (int mode, sigset_t * mask, sigset_t * omask) 60*0Sstevel@tonic-gate { 61*0Sstevel@tonic-gate sigset_t current = sigsetmask(0); 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate if (omask) *omask = current; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate if (mode==SIG_BLOCK) 66*0Sstevel@tonic-gate current |= *mask; 67*0Sstevel@tonic-gate else if (mode==SIG_UNBLOCK) 68*0Sstevel@tonic-gate current &= ~*mask; 69*0Sstevel@tonic-gate else if (mode==SIG_SETMASK) 70*0Sstevel@tonic-gate current = *mask; 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate sigsetmask(current); 73*0Sstevel@tonic-gate return 0; 74*0Sstevel@tonic-gate } 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate int 77*0Sstevel@tonic-gate sigsuspend (sigset_t * mask) 78*0Sstevel@tonic-gate { 79*0Sstevel@tonic-gate return sigpause(*mask); 80*0Sstevel@tonic-gate } 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate int 83*0Sstevel@tonic-gate sigdelset (sigset_t * mask, int sig) 84*0Sstevel@tonic-gate { 85*0Sstevel@tonic-gate *mask &= ~sigmask(sig); 86*0Sstevel@tonic-gate return 0; 87*0Sstevel@tonic-gate } 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate int 90*0Sstevel@tonic-gate sigaddset (sigset_t * mask, int sig) 91*0Sstevel@tonic-gate { 92*0Sstevel@tonic-gate *mask |= sigmask(sig); 93*0Sstevel@tonic-gate return 0; 94*0Sstevel@tonic-gate } 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate int 97*0Sstevel@tonic-gate sigismember (sigset_t * mask, int sig) 98*0Sstevel@tonic-gate { 99*0Sstevel@tonic-gate return (*mask & sigmask(sig)) != 0; 100*0Sstevel@tonic-gate } 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate #endif 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 105