/* @(#)sigset.c 4.1 (Berkeley) 12/28/82 */
* signal system call interface package.
#define BYTESPERVEC 4 /* size of machine language vector */
extern char mvectors
[NSIG
+1][BYTESPERVEC
];
static int (*cactions
[NSIG
+1])(); /* saved callers signal actions */
static char setflg
[NSIG
+1]; /* =1 means action perm ``sigset'' */
* old signal protocol. when signal occurs, further
* instances of same signal are not blocked, so that
* recursive signals are possible. the action will
* not be re-enabled by these routines when return
* is made from the interrupt (compare sigset).
signal(signum
, action
))()
register int (*action
)();
register int (*retval
)();
if (signum
<= 0 || signum
> NSIG
) {
retval
= cactions
[signum
];
cactions
[signum
] = action
;
if (action
!= SIG_IGN
&& action
!= SIG_DFL
&& action
!= SIG_HOLD
)
action
= DEFERSIG(mvectors
[signum
]);
action
= (int (*)())(int)mvectors
[signum
];
action
= DEFERSIG(_sigcatch
);
action
= sigsys(signum
, action
);
if (action
== SIG_IGN
|| action
== SIG_DFL
|| action
== SIG_HOLD
)
setflg
[signum
] = 0; /* 'tis fleeting (madness may take its toll) */
* set ``permanent'' action for this signal. if a function,
* it will be deferred when interupt occurs and enabled again
* when return occurs. after sigset, sighold and sigrelse can
* be used to protect signum signal critical sections.
sigset(signum
, action
))()
register int (*action
)();
register int (*retval
)();
if (signum
<= 0 || signum
> NSIG
) {
retval
= cactions
[signum
];
cactions
[signum
] = action
;
if (action
!= SIG_IGN
&& action
!= SIG_DFL
&& action
!= SIG_HOLD
)
action
= DEFERSIG(_sigcatch
);
action
= sigsys(signum
, action
);
if (action
== SIG_IGN
|| action
== SIG_DFL
|| action
== SIG_HOLD
)
setflg
[signum
] = 1; /* don't want to lose control! */
* temporarily hold a signal until further notice
* via sigpause or sigrelse
if (signum
<= 0 || signum
> NSIG
) {
sigsys(signum
, SIG_HOLD
);
* atomically release the signal and pause
* if no signals pending. signal will normally
* be held on return (unless an routine called at
* interrupt time resets it).
if (signum
<= 0 || signum
> NSIG
|| setflg
[signum
] == 0) {
sigsys(signum
|SIGDOPAUSE
, DEFERSIG(mvectors
[signum
]));
sigsys(signum
|SIGDOPAUSE
, DEFERSIG(_sigcatch
));
* re-enable signals after sighold or possibly after sigpause
if (signum
<= 0 || signum
> NSIG
|| setflg
[signum
] == 0) {
sigsys(signum
, DEFERSIG(mvectors
[signum
]));
sigsys(signum
, DEFERSIG(_sigcatch
));
* called at interrupt time. on pdp11 assembly language
* routine resets signal catch to returned action, if
* returned action is not SIG_DFL.
(*cactions
[signum
])(signum
); /* call the C routine */
return (DEFERSIG(mvectors
[signum
]);
return (SIG_DFL
); /* old protocol */
* called at interrupt time. on vax, sigpeel will peel
* off the interrupt frames and reenable the signal with
* the argument action (cleanly). if the action is
* SIG_DFL sigpeel will do nothing, but we can as well
* return ourselves without its help.
_sigcatch(signum
, code
, xx
, ps
, pc
)
register int (*act
)() = cactions
[signum
];
{ asm("callg (ap),(r10)"); }
sigpeel(signum
, DEFERSIG(_sigcatch
));
/* old protocol, just return */