Use sys_signame[].

This commit is contained in:
mycroft 1993-08-06 21:50:14 +00:00
parent a35ec39674
commit f637854f04
3 changed files with 31 additions and 38 deletions

View File

@ -1,16 +1,16 @@
# $Id: Makefile,v 1.5 1993/08/02 17:18:50 mycroft Exp $
# $Id: Makefile,v 1.6 1993/08/06 21:50:14 mycroft Exp $
PROG= sh
SRCS= builtins.c cd.c dirent.c echo.c error.c eval.c exec.c expand.c \
input.c jobs.c mail.c main.c memalloc.c miscbltin.c \
mystring.c nodes.c options.c parser.c redir.c show.c signames.c \
mystring.c nodes.c options.c parser.c redir.c show.c \
syntax.c trap.c output.c var.c
OBJS+= init.o
CFLAGS+=-DSHELL -I. -I${.CURDIR}
.PATH: ${.CURDIR}/bltin
CLEANFILES+=\
builtins.c builtins.h init.c mkinit mknodes mksignames mksyntax \
nodes.c nodes.h signames.c signames.h syntax.c syntax.h token.def
builtins.c builtins.h init.c mkinit mknodes mksyntax \
nodes.c nodes.h syntax.c syntax.h token.def
.depend parser.o: token.def
token.def: mktokens
@ -32,12 +32,6 @@ nodes.c nodes.h: mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
mknodes: ${.CURDIR}/mknodes.c
${CC} ${CFLAGS} ${.CURDIR}/mknodes.c -o $@
signames.c signames.h: mksignames
./mksignames
mksignames: ${.CURDIR}/mksignames.c
${CC} ${CFLAGS} ${.CURDIR}/mksignames.c -o $@
syntax.c syntax.h: mksyntax
./mksyntax

View File

@ -36,7 +36,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)jobs.c 5.1 (Berkeley) 3/7/91";*/
static char rcsid[] = "$Id: jobs.c,v 1.6 1993/08/01 18:58:14 mycroft Exp $";
static char rcsid[] = "$Id: jobs.c,v 1.7 1993/08/06 21:50:16 mycroft Exp $";
#endif /* not lint */
#include "shell.h"
@ -50,7 +50,6 @@ static char rcsid[] = "$Id: jobs.c,v 1.6 1993/08/01 18:58:14 mycroft Exp $";
#include "jobs.h"
#include "options.h"
#include "trap.h"
#include "signames.h"
#include "syntax.h"
#include "input.h"
#include "output.h"
@ -61,6 +60,7 @@ static char rcsid[] = "$Id: jobs.c,v 1.6 1993/08/01 18:58:14 mycroft Exp $";
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#ifdef BSD
#include <sys/types.h>
#include <sys/wait.h>
@ -123,8 +123,8 @@ setjobctl(on) {
return;
}
if (initialpgrp == -1)
initialpgrp = getpgrp(0);
else if (initialpgrp != getpgrp(0)) {
initialpgrp = getpgrp();
else if (initialpgrp != getpgrp()) {
killpg(initialpgrp, SIGTTIN);
continue;
}
@ -272,8 +272,8 @@ showjobs(change) {
if ((i & 0xFF) == 0177)
i >>= 8;
#endif
if ((i & 0x7F) <= MAXSIG && sigmesg[i & 0x7F])
scopy(sigmesg[i & 0x7F], s);
if ((i & 0x7F) < NSIG && sys_siglist[i & 0x7F])
scopy(sys_siglist[i & 0x7F], s);
else
fmtstr(s, 64, "Signal %d", i & 0x7F);
if (i & 0x80)
@ -626,7 +626,7 @@ waitforjob(jp)
register struct job *jp;
{
#if JOBS
int mypgrp = getpgrp(0);
int mypgrp = getpgrp();
#endif
int status;
int st;
@ -736,8 +736,8 @@ dowait(block, job)
if (status == SIGTSTP && rootshell && iflag)
outfmt(out2, "%%%d ", job - jobtab + 1);
#endif
if (status <= MAXSIG && sigmesg[status])
out2str(sigmesg[status]);
if (status < NSIG && sys_siglist[status])
out2str(sys_siglist[status]);
else
outfmt(out2, "Signal %d", status);
if (core)

View File

@ -36,7 +36,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)trap.c 5.2 (Berkeley) 4/12/91";*/
static char rcsid[] = "$Id: trap.c,v 1.4 1993/08/01 18:57:59 mycroft Exp $";
static char rcsid[] = "$Id: trap.c,v 1.5 1993/08/06 21:50:18 mycroft Exp $";
#endif /* not lint */
#include "shell.h"
@ -46,7 +46,6 @@ static char rcsid[] = "$Id: trap.c,v 1.4 1993/08/01 18:57:59 mycroft Exp $";
#include "jobs.h"
#include "options.h"
#include "syntax.h"
#include "signames.h"
#include "output.h"
#include "memalloc.h"
#include "error.h"
@ -69,10 +68,10 @@ static char rcsid[] = "$Id: trap.c,v 1.4 1993/08/01 18:57:59 mycroft Exp $";
extern char nullstr[1]; /* null string */
char *trap[MAXSIG+1]; /* trap handler commands */
MKINIT char sigmode[MAXSIG]; /* current value of signal */
char gotsig[MAXSIG]; /* indicates specified signal received */
int pendingsigs; /* indicates some signal received */
char *trap[NSIG]; /* trap handler commands */
MKINIT char sigmode[NSIG]; /* current value of signal */
char gotsig[NSIG]; /* indicates specified signal received */
int pendingsigs; /* indicates some signal received */
/*
* The trap builtin.
@ -84,7 +83,7 @@ trapcmd(argc, argv) char **argv; {
int signo;
if (argc <= 1) {
for (signo = 0 ; signo <= MAXSIG ; signo++) {
for (signo = 0 ; signo < NSIG ; signo++) {
if (trap[signo] != NULL)
out1fmt("%d: %s\n", signo, trap[signo]);
}
@ -96,7 +95,7 @@ trapcmd(argc, argv) char **argv; {
else
action = *ap++;
while (*ap) {
if ((signo = number(*ap)) < 0 || signo > MAXSIG)
if ((signo = number(*ap)) < 0 || signo >= NSIG)
error("%s: bad trap", *ap);
INTOFF;
if (action)
@ -122,7 +121,7 @@ void
clear_traps() {
char **tp;
for (tp = trap ; tp <= &trap[MAXSIG] ; tp++) {
for (tp = trap ; tp < &trap[NSIG] ; tp++) {
if (*tp && **tp) { /* trap not NULL or SIG_IGN */
INTOFF;
ckfree(*tp);
@ -183,7 +182,7 @@ setsignal(signo) {
#endif
}
}
t = &sigmode[signo - 1];
t = &sigmode[signo];
if (*t == 0) { /* current setting unknown */
/*
* There is a race condition here if action is not S_IGN.
@ -215,22 +214,22 @@ setsignal(signo) {
void
ignoresig(signo) {
if (sigmode[signo - 1] != S_IGN && sigmode[signo - 1] != S_HARD_IGN) {
if (sigmode[signo] != S_IGN && sigmode[signo] != S_HARD_IGN) {
signal(signo, SIG_IGN);
}
sigmode[signo - 1] = S_HARD_IGN;
sigmode[signo] = S_HARD_IGN;
}
#ifdef mkinit
INCLUDE "signames.h"
INCLUDE <sys/signal.h>
INCLUDE "trap.h"
SHELLPROC {
char *sm;
clear_traps();
for (sm = sigmode ; sm < sigmode + MAXSIG ; sm++) {
for (sm = sigmode ; sm < sigmode + NSIG ; sm++) {
if (*sm == S_IGN)
*sm = S_HARD_IGN;
}
@ -250,7 +249,7 @@ onsig(signo) {
onint();
return;
}
gotsig[signo - 1] = 1;
gotsig[signo] = 1;
pendingsigs++;
}
@ -268,12 +267,12 @@ dotrap() {
for (;;) {
for (i = 1 ; ; i++) {
if (gotsig[i - 1])
break;
if (i >= MAXSIG)
if (i >= NSIG)
goto done;
if (gotsig[i])
break;
}
gotsig[i - 1] = 0;
gotsig[i] = 0;
savestatus=exitstatus;
evalstring(trap[i]);
exitstatus=savestatus;