11366Scsgr/*
21366Scsgr * Copyright (c) 1989, 1993
31366Scsgr *	The Regents of the University of California.  All rights reserved.
41366Scsgr *
51366Scsgr * Redistribution and use in source and binary forms, with or without
61366Scsgr * modification, are permitted provided that the following conditions
71366Scsgr * are met:
81366Scsgr * 1. Redistributions of source code must retain the above copyright
91366Scsgr *    notice, this list of conditions and the following disclaimer.
101366Scsgr * 2. Redistributions in binary form must reproduce the above copyright
111366Scsgr *    notice, this list of conditions and the following disclaimer in the
121366Scsgr *    documentation and/or other materials provided with the distribution.
131366Scsgr * 4. Neither the name of the University nor the names of its contributors
141366Scsgr *    may be used to endorse or promote products derived from this software
151366Scsgr *    without specific prior written permission.
161366Scsgr *
171366Scsgr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181366Scsgr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191366Scsgr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201366Scsgr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211366Scsgr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221366Scsgr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231366Scsgr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241366Scsgr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251366Scsgr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261366Scsgr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271366Scsgr * SUCH DAMAGE.
281366Scsgr */
291366Scsgr
301366Scsgr#if defined(LIBC_SCCS) && !defined(lint)
311366Scsgrstatic char sccsid[] = "@(#)siginterrupt.c	8.1 (Berkeley) 6/4/93";
321366Scsgr#endif /* LIBC_SCCS and not lint */
3319411Swosch#include <sys/cdefs.h>
341366Scsgr__FBSDID("$FreeBSD$");
351366Scsgr
361366Scsgr#include "namespace.h"
371366Scsgr#include <signal.h>
381366Scsgr#include "un-namespace.h"
391376Scsgr#include "libc_private.h"
401376Scsgr
411366Scsgr/*
421366Scsgr * Set signal state to prevent restart of system calls
431366Scsgr * after an instance of the indicated signal.
441366Scsgr */
451366Scsgrint
461366Scsgrsiginterrupt(sig, flag)
471366Scsgr	int sig, flag;
481366Scsgr{
4919411Swosch	extern sigset_t _sigintr __hidden;
501366Scsgr	struct sigaction sa;
511366Scsgr	int ret;
521366Scsgr
531366Scsgr	if ((ret = _sigaction(sig, (struct sigaction *)0, &sa)) < 0)
541366Scsgr		return (ret);
551366Scsgr	if (flag) {
561366Scsgr		sigaddset(&_sigintr, sig);
571366Scsgr		sa.sa_flags &= ~SA_RESTART;
581366Scsgr	} else {
591366Scsgr		sigdelset(&_sigintr, sig);
601366Scsgr		sa.sa_flags |= SA_RESTART;
611366Scsgr	}
621366Scsgr	return (_sigaction(sig, &sa, (struct sigaction *)0));
631366Scsgr}
641366Scsgr