sigblock,sigmask,sigsetmask ... for SYS V?

Scott R. Presnell%Cohen srp at babar.mmwb.ucsf.edu
Sun Jun 23 05:56:25 AEST 1991


hpn at regentdb.osrhe.uoknor.edu (Huy Nguyen / (405) 721-3798) writes:

>Does anyone know of a library package, hacks, etc to emulate these BSD
>signal routines for SYS V?  

>Huy Nguyen
>hpn at regentdb.osrhe.uoknor.edu

I've used the following in the past as a quick hack (NSIG can usually be
found in /usr/include/sys/signals.h):

/* Mask of held signals */
static int sigheld = 0;

int sigblock (sigs)
int sigs;
{
  int i,old;
  for (i = 0; i < NSIG; i++)
    if (sigs & sigbit (i))
  sighold (i);
  old = sigheld;
  sigheld |= sigs;
  return(old);
}

sigsetmask(sigset)
int sigset;
{
  int newheld,newrel,tmp;
  newheld = sigset & ~sigheld;
  newrel = sigheld & ~sigset;
  tmp = sigblock(newheld);
  sigfree(newrel);
}

sigfree (sigs) 
int sigs;
{
  int i;
  for (i = 0; i < NSIG; i++)
    if (sigs & sigbit (i))
      sigrelse (i);
  sigheld &= ~sigs;
}

sigbit (i)
int i;
{
  return 1 << (i - 1);
}


	Hope this helps.

	- Scott Presnell (srp at cgl.ucsf.edu)
--
Scott Presnell				        +1 (415) 476-9890
Pharm. Chem., S-926				Internet: srp at cgl.ucsf.edu
University of California			UUCP: ...ucbvax!ucsfcgl!srp
San Francisco, CA. 94143-0446			Bitnet: srp at ucsfcgl.bitnet



More information about the Comp.unix.internals mailing list