xref: /csrg-svn/lib/libc/gen/siginterrupt.c (revision 35302)
122110Smckusick /*
2*35302Sbostic  * Copyright (c) 1988 Regents of the University of California.
3*35302Sbostic  * All rights reserved.
4*35302Sbostic  *
5*35302Sbostic  * Redistribution and use in source and binary forms are permitted
6*35302Sbostic  * provided that the above copyright notice and this paragraph are
7*35302Sbostic  * duplicated in all such forms and that any documentation,
8*35302Sbostic  * advertising materials, and other materials related to such
9*35302Sbostic  * distribution and use acknowledge that the software was developed
10*35302Sbostic  * by the University of California, Berkeley.  The name of the
11*35302Sbostic  * University may not be used to endorse or promote products derived
12*35302Sbostic  * from this software without specific prior written permission.
13*35302Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*35302Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*35302Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1622110Smckusick  */
1718295Smckusick 
1826590Sdonn #if defined(LIBC_SCCS) && !defined(lint)
19*35302Sbostic static char sccsid[] = "@(#)siginterrupt.c	5.3 (Berkeley) 08/02/88";
20*35302Sbostic #endif /* LIBC_SCCS and not lint */
2122110Smckusick 
2218295Smckusick #include <signal.h>
2318295Smckusick 
2418295Smckusick /*
2518295Smckusick  * Set signal state to prevent restart of system calls
2618295Smckusick  * after an instance of the indicated signal.
2718295Smckusick  */
2818295Smckusick siginterrupt(sig, flag)
2918295Smckusick 	int sig, flag;
3018295Smckusick {
3118295Smckusick 	struct sigvec sv;
3218295Smckusick 	int ret;
3318295Smckusick 
34*35302Sbostic 	if ((ret = sigvec(sig, (struct sigvec *)0, &sv)) < 0)
3518295Smckusick 		return (ret);
3618295Smckusick 	if (flag)
3718295Smckusick 		sv.sv_flags |= SV_INTERRUPT;
3818295Smckusick 	else
3918295Smckusick 		sv.sv_flags &= ~SV_INTERRUPT;
40*35302Sbostic 	return (sigvec(sig, &sv, (struct sigvec *)0));
4118295Smckusick }
42