sigcompat.c revision 1574
1263105Sgjb/*
2263105Sgjb * Copyright (c) 1989, 1993
3263105Sgjb *	The Regents of the University of California.  All rights reserved.
4263105Sgjb *
5263105Sgjb * Redistribution and use in source and binary forms, with or without
6263105Sgjb * modification, are permitted provided that the following conditions
7263105Sgjb * are met:
8263105Sgjb * 1. Redistributions of source code must retain the above copyright
9263105Sgjb *    notice, this list of conditions and the following disclaimer.
10263105Sgjb * 2. Redistributions in binary form must reproduce the above copyright
11263105Sgjb *    notice, this list of conditions and the following disclaimer in the
12263105Sgjb *    documentation and/or other materials provided with the distribution.
13263105Sgjb * 3. All advertising materials mentioning features or use of this software
14263105Sgjb *    must display the following acknowledgement:
15263105Sgjb *	This product includes software developed by the University of
16263105Sgjb *	California, Berkeley and its contributors.
17263105Sgjb * 4. Neither the name of the University nor the names of its contributors
18263105Sgjb *    may be used to endorse or promote products derived from this software
19263105Sgjb *    without specific prior written permission.
20263105Sgjb *
21263105Sgjb * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22263105Sgjb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23263105Sgjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24263105Sgjb * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25263105Sgjb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26263105Sgjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27263105Sgjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28263105Sgjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29263105Sgjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30263105Sgjb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31263105Sgjb * SUCH DAMAGE.
32263105Sgjb */
33263105Sgjb
34263105Sgjb#if defined(LIBC_SCCS) && !defined(lint)
35263105Sgjbstatic char sccsid[] = "@(#)sigcompat.c	8.1 (Berkeley) 6/2/93";
36263105Sgjb#endif /* LIBC_SCCS and not lint */
37263105Sgjb
38309317Sdexuan#include <sys/param.h>
39263105Sgjb#include <signal.h>
40263105Sgjb
41263105Sgjbsigvec(signo, sv, osv)
42263105Sgjb	int signo;
43263105Sgjb	struct sigvec *sv, *osv;
44263105Sgjb{
45263105Sgjb	int ret;
46263105Sgjb
47263105Sgjb	if (sv)
48263105Sgjb		sv->sv_flags ^= SV_INTERRUPT;	/* !SA_INTERRUPT */
49263105Sgjb	ret = sigaction(signo, (struct sigaction *)sv, (struct sigaction *)osv);
50263105Sgjb	if (ret == 0 && osv)
51263105Sgjb		osv->sv_flags ^= SV_INTERRUPT;	/* !SA_INTERRUPT */
52263105Sgjb	return (ret);
53263105Sgjb}
54263105Sgjb
55263105Sgjbsigsetmask(mask)
56263105Sgjb	int mask;
57263105Sgjb{
58263105Sgjb	int omask, n;
59263105Sgjb
60263105Sgjb	n = sigprocmask(SIG_SETMASK, (sigset_t *) &mask, (sigset_t *) &omask);
61263105Sgjb	if (n)
62263105Sgjb		return (n);
63263105Sgjb	return (omask);
64263105Sgjb}
65263105Sgjb
66263105Sgjbsigblock(mask)
67263105Sgjb	int mask;
68263105Sgjb{
69263105Sgjb	int omask, n;
70263105Sgjb
71263105Sgjb	n = sigprocmask(SIG_BLOCK, (sigset_t *) &mask, (sigset_t *) &omask);
72263105Sgjb	if (n)
73263105Sgjb		return (n);
74263105Sgjb	return (omask);
75263105Sgjb}
76263105Sgjb
77263105Sgjbsigpause(mask)
78263105Sgjb	int mask;
79263105Sgjb{
80263105Sgjb	return (sigsuspend((sigset_t *)&mask));
81263105Sgjb}
82263105Sgjb