xref: /csrg-svn/lib/libc/gen/siginterrupt.c (revision 38790)
122110Smckusick /*
2*38790Skarels  * Copyright (c) 1989 Regents of the University of California.
335302Sbostic  * All rights reserved.
435302Sbostic  *
535302Sbostic  * Redistribution and use in source and binary forms are permitted
635302Sbostic  * provided that the above copyright notice and this paragraph are
735302Sbostic  * duplicated in all such forms and that any documentation,
835302Sbostic  * advertising materials, and other materials related to such
935302Sbostic  * distribution and use acknowledge that the software was developed
1035302Sbostic  * by the University of California, Berkeley.  The name of the
1135302Sbostic  * University may not be used to endorse or promote products derived
1235302Sbostic  * from this software without specific prior written permission.
1335302Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1435302Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1535302Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1622110Smckusick  */
1718295Smckusick 
1826590Sdonn #if defined(LIBC_SCCS) && !defined(lint)
19*38790Skarels static char sccsid[] = "@(#)siginterrupt.c	5.4 (Berkeley) 08/26/89";
2035302Sbostic #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 {
31*38790Skarels 	extern sigset_t _sigintr;
32*38790Skarels 	struct sigaction sa;
3318295Smckusick 	int ret;
3418295Smckusick 
35*38790Skarels 	if ((ret = sigaction(sig, (struct sigaction *)0, &sa)) < 0)
3618295Smckusick 		return (ret);
37*38790Skarels 	if (flag) {
38*38790Skarels 		sigaddset(&_sigintr, sig);
39*38790Skarels 		sa.sa_flags &= ~SA_RESTART;
40*38790Skarels 	} else {
41*38790Skarels 		sigdelset(&_sigintr, sig);
42*38790Skarels 		sa.sa_flags |= SA_RESTART;
43*38790Skarels 	}
44*38790Skarels 	return (sigaction(sig, &sa, (struct sigaction *)0));
4518295Smckusick }
46