Trailing-Edge
-
PDP-10 Archives
-
SRI_NIC_PERM_FS_1_19910112
-
c/lib5/ssigna.c
There are 5 other files named ssigna.c in the archive. Click here to see a list.
/*
* SSIGNAL - set a softsig handler
* GSIGNAL - raise software signal
*
* Copyright (C) 1987 by Ian Macky, SRI International
*/
#include "c-env.h"
#include "errno.h"
#include "signal.h"
static int (*_uhandler[_SS_NSIGS])(); /* handler or 0 if none for softsig */
int (*ssignal(softsig, func))()
int softsig;
int (*func)();
{
int index, (*old_func)();
if ((index = softsig - _SS_FIRST) < 0 || index >= _SS_NSIGS) {
errno = EINVAL; /* softsig out of range */
return (int (*)()) SIG_ERR;
}
old_func = _uhandler[index]; /* save old handler */
_uhandler[index] = func; /* set the new one */
return old_func; /* return the old handler */
}
int gsignal(softsig)
int softsig;
{
int index;
if ((index = softsig - _SS_FIRST) < 0 || index >= _SS_NSIGS ||
!_uhandler[index]) {
errno = EINVAL; /* softsig out of range */
return (int) SIG_ERR; /* or no handler */
}
return (*_uhandler[index])(softsig); /* call the handler */
}