siginterrupt.c revision 90039
176866Skris/* 276866Skris * Copyright (c) 1989, 1993 376866Skris * The Regents of the University of California. All rights reserved. 476866Skris * 576866Skris * Redistribution and use in source and binary forms, with or without 676866Skris * modification, are permitted provided that the following conditions 776866Skris * are met: 876866Skris * 1. Redistributions of source code must retain the above copyright 976866Skris * notice, this list of conditions and the following disclaimer. 1076866Skris * 2. Redistributions in binary form must reproduce the above copyright 1176866Skris * notice, this list of conditions and the following disclaimer in the 1276866Skris * documentation and/or other materials provided with the distribution. 1376866Skris * 3. All advertising materials mentioning features or use of this software 1476866Skris * must display the following acknowledgement: 1576866Skris * This product includes software developed by the University of 1676866Skris * California, Berkeley and its contributors. 1776866Skris * 4. Neither the name of the University nor the names of its contributors 1876866Skris * may be used to endorse or promote products derived from this software 1976866Skris * without specific prior written permission. 2076866Skris * 2176866Skris * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2276866Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2376866Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2476866Skris * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2576866Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2676866Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2776866Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2876866Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2976866Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3076866Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3176866Skris * SUCH DAMAGE. 3276866Skris */ 3376866Skris 3476866Skris#if defined(LIBC_SCCS) && !defined(lint) 3576866Skrisstatic char sccsid[] = "@(#)siginterrupt.c 8.1 (Berkeley) 6/4/93"; 3676866Skris#endif /* LIBC_SCCS and not lint */ 3776866Skris#include <sys/cdefs.h> 3876866Skris__FBSDID("$FreeBSD: head/lib/libc/gen/siginterrupt.c 90039 2002-02-01 00:57:29Z obrien $"); 3976866Skris 4076866Skris#include "namespace.h" 4176866Skris#include <signal.h> 4276866Skris#include "un-namespace.h" 4376866Skris#include "libc_private.h" 4476866Skris 4576866Skris/* 4676866Skris * Set signal state to prevent restart of system calls 4776866Skris * after an instance of the indicated signal. 4876866Skris */ 4976866Skrisint 5076866Skrissiginterrupt(sig, flag) 5176866Skris int sig, flag; 5276866Skris{ 5376866Skris extern sigset_t _sigintr; 5476866Skris struct sigaction sa; 5576866Skris int ret; 5676866Skris 5776866Skris if ((ret = _sigaction(sig, (struct sigaction *)0, &sa)) < 0) 5876866Skris return (ret); 5976866Skris if (flag) { 6076866Skris sigaddset(&_sigintr, sig); 6176866Skris sa.sa_flags &= ~SA_RESTART; 6276866Skris } else { 6376866Skris sigdelset(&_sigintr, sig); 6476866Skris sa.sa_flags |= SA_RESTART; 6576866Skris } 6676866Skris return (_sigaction(sig, &sa, (struct sigaction *)0)); 6776866Skris} 6876866Skris