register int resetsig;
if (t->words[1] == NULL) {
- for (i=0; i<=_NSIG; i++)
+ for (i=0; i<_NSIG; i++)
if (trap[i]) {
prn(i);
prs(": ");
{
register int n;
- if ((n = getn(s)) < 0 || n > _NSIG) {
+ if ((n = getn(s)) < 0 || n >= _NSIG) {
err("trap: bad signal number");
n = 0;
}
}
*e.linep = 0;
/* allow trapped signals */
- for (i=0; i<=_NSIG; i++)
+ for (i=0; i<_NSIG; i++)
if (ourtrap[i] && signal(i, SIG_IGN) != SIG_IGN)
signal(i, SIG_DFL);
dup2(pf[1], 1);
}
if (sig < 0) { /* numeric? */
ul = strtoul(argv[1] + 1, &end, 10);
- if (end == argv[1] + 1 || *end != 0 || ul > _NSIG) usage();
+ if (end == argv[1] + 1 || *end != 0 || ul >= _NSIG) usage();
sig = ul;
}
argv++;
/* Reset signals to default values. */
sa.sa_handler = SIG_DFL;
- for (n = 1; n <= _NSIG; ++n) sigaction(n, &sa, NULL);
+ for (n = 1; n < _NSIG; ++n) sigaction(n, &sa, NULL);
/* Execute the user's shell. */
execve(sh, argx, env);
*===========================================================================*/
PUBLIC void cause_sig(proc_nr, sig_nr)
int proc_nr; /* process to be signalled */
-int sig_nr; /* signal to be sent, 1 to _NSIG */
+int sig_nr; /* signal to be sent */
{
/* A system process wants to send a signal to a process. Examples are:
* - HARDWARE wanting to cause a SIGSEGV after a CPU exception
proc_nr_e= m_ptr->SIG_ENDPT;
if (!isokendpt(proc_nr_e, &proc_nr)) return(EINVAL);
- if (sig_nr > _NSIG) return(EINVAL);
+ if (sig_nr >= _NSIG) return(EINVAL);
if (iskerneln(proc_nr)) return(EPERM);
/* Set pending signal to be processed by the PM. */
int
raise(int sig)
{
- if (sig < 0 || sig > _NSIG)
+ if (sig < 0 || sig >= _NSIG)
return -1;
return _kill(_getpid(), sig);
}
{
struct sigaction sa, osa;
- if (sig <= 0 || sig > _NSIG || sig == SIGKILL) {
+ if (sig <= 0 || sig >= _NSIG || sig == SIGKILL) {
errno = EINVAL;
return(SIG_ERR);
}
/* System processes use simpler macros with no range error checking (defined in
* signal.h). The ANSI signal() implementation now also uses the macro
* versions, which makes hiding of the functions here a historical remains.
+ *
+ * _NSIG is supposed to be the highest signal number plus one.
*/
#define sigaddset _sigaddset
#define sigdelset _sigdelset
/* Low bit of signal masks. */
#define SIGBIT_0 ((sigset_t) 1)
-/* Mask of valid signals (0 - _NSIG). */
-#define SIGMASK (((SIGBIT_0 << _NSIG) << 1) - 1)
+/* Mask of valid signals (0 - (_NSIG-1)). */
+#define SIGMASK ((SIGBIT_0 << _NSIG) - 1)
-#define sigisvalid(signo) ((unsigned) (signo) <= _NSIG)
+#define sigisvalid(signo) ((unsigned) (signo) < _NSIG)
PUBLIC int sigaddset(set, signo)
sigset_t *set;
if (sigdelset(&s_nokill, SIGKILL) != 0) e(8);
s_nokill_stop = s_nokill;
if (sigdelset(&s_nokill_stop, SIGSTOP) != 0) e(8);
-#ifndef _MINIX /* XXX - should unsupported signals be <= _NSIG? */
- if (SIGSTOP > _NSIG) e(666);
- if (SIGSTOP <= _NSIG && sigdelset(&s_nokill, SIGSTOP) != 0) e(888);
-#endif /* _MINIX */
+ if (SIGSTOP >= _NSIG) e(666);
+ if (SIGSTOP < _NSIG && sigdelset(&s_nokill, SIGSTOP) != 0) e(888);
/* Now get most of the signals into default state. Don't change SIGINT
* or SIGQUIT, so this program can be killed. SIGKILL is also special.
if (signal(SIGINT, catch1) != SIG_DFL) e(11);
/* Verify that SIG_ERR is correctly generated. */
- if (signal(_NSIG + 1, catch1) != SIG_ERR) e(12);
+ if (signal(_NSIG, catch1) != SIG_ERR) e(12);
if (signal(0, catch1) != SIG_ERR) e(13);
if (signal(-1, SIG_DFL) != SIG_ERR) e(14);
sigset_t sigset_var;
/* Clear the signal state. */
- for (i = 1; i <= _NSIG; i++) signal(i, SIG_IGN);
- for (i = 1; i <= _NSIG; i++) signal(i, SIG_DFL);
+ for (i = 1; i < _NSIG; i++) signal(i, SIG_IGN);
+ for (i = 1; i < _NSIG; i++) signal(i, SIG_DFL);
sigfillset(&sigset_var);
sigprocmask(SIG_UNBLOCK, &sigset_var, (sigset_t *)NULL);
}