date and time created 91/03/07 10:23:53 by bostic
[unix-history] / usr / src / lib / libc / gen / siginterrupt.c
CommitLineData
b8f253e8 1/*
8a376f64 2 * Copyright (c) 1989 Regents of the University of California.
84cb68a1
KB
3 * All rights reserved.
4 *
269a7923 5 * %sccs.include.redist.c%
b8f253e8
KM
6 */
7
2ce81398 8#if defined(LIBC_SCCS) && !defined(lint)
269a7923 9static char sccsid[] = "@(#)siginterrupt.c 5.5 (Berkeley) %G%";
84cb68a1 10#endif /* LIBC_SCCS and not lint */
6fa13af1
KM
11
12#include <signal.h>
13
14/*
15 * Set signal state to prevent restart of system calls
16 * after an instance of the indicated signal.
17 */
18siginterrupt(sig, flag)
19 int sig, flag;
20{
8a376f64
MK
21 extern sigset_t _sigintr;
22 struct sigaction sa;
6fa13af1
KM
23 int ret;
24
8a376f64 25 if ((ret = sigaction(sig, (struct sigaction *)0, &sa)) < 0)
6fa13af1 26 return (ret);
8a376f64
MK
27 if (flag) {
28 sigaddset(&_sigintr, sig);
29 sa.sa_flags &= ~SA_RESTART;
30 } else {
31 sigdelset(&_sigintr, sig);
32 sa.sa_flags |= SA_RESTART;
33 }
34 return (sigaction(sig, &sa, (struct sigaction *)0));
6fa13af1 35}