/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* signal critical region support
*/
#include <ast.h>
#include <sig.h>
static struct
{
int sig;
int op;
}
{
#ifdef SIGPIPE
#endif
#ifdef SIGQUIT
#endif
#ifdef SIGHUP
#endif
#if defined(SIGCHLD) && ( !defined(SIGCLD) || SIGCHLD != SIGCLD || _lib_sigprocmask || _lib_sigsetmask )
#endif
#ifdef SIGTSTP
#endif
#ifdef SIGTTIN
#endif
#ifdef SIGTTOU
#endif
};
#ifndef SIG_SETMASK
#endif
#if !_lib_sigprocmask && !_lib_sigsetmask
/*
* hold last signal for later delivery
*/
static void
{
}
#endif
/*
* critical signal region handler
*
* op>0 new region according to SIG_REG_*, return region level
* op==0 pop region, return region level
* op<0 return non-zero if any signals held in current region
*
* signals[] held until region popped
*/
int
{
register int i;
static int region;
static int level;
#if _lib_sigprocmask
#else
#if _lib_sigsetmask
static long mask;
#else
#endif
#endif
if (op > 0)
{
if (!level++)
{
if (op & SIG_REG_SET)
level--;
#if _lib_sigprocmask
sigemptyset(&nmask);
for (i = 0; i < elementsof(signals); i++)
#else
#if _lib_sigsetmask
mask = 0;
for (i = 0; i < elementsof(signals); i++)
#else
hold = 0;
for (i = 0; i < elementsof(signals); i++)
{
}
#endif
#endif
}
return level;
}
else if (op < 0)
{
#if _lib_sigprocmask
sigpending(&nmask);
for (i = 0; i < elementsof(signals); i++)
{
return 1;
}
return 0;
#else
#if _lib_sigsetmask
/* no way to get pending signals without installing handler */
return 0;
#else
return hold != 0;
#endif
#endif
}
else
{
/*
* a vfork() may have intervened so we
* allow apparent nesting mismatches
*/
if (--level <= 0)
{
level = 0;
#if _lib_sigprocmask
#else
#if _lib_sigsetmask
#else
for (i = 0; i < elementsof(signals); i++)
if (hold)
{
for (i = 0; i < elementsof(signals); i++)
{
}
pause();
}
#endif
#endif
}
return level;
}
}