1 diff -urN netbsd-sh/jobs.c ash-0.3.7.orig/jobs.c
2 --- netbsd-sh/jobs.c Tue May 23 12:03:19 2000
3 +++ ash-0.3.7.orig/jobs.c Mon Apr 23 22:16:46 2001
12 + extern char *signal_names[];
21 +"Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or\n"
22 +"kill -l [exitstatus]"
26 + if (*argv[1] == '-') {
27 + signo = decode_signal(argv[1]+1);
31 + while ((c = nextopt("ls:")) != '\0')
37 + signo = decode_signal(optarg);
41 + "nextopt returned character code 0%o", c);
47 + if (!list && signo < 0)
50 + if ((signo < 0 || !*argptr) ^ list) {
52 +"Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or\n"
53 +"kill -l [exitstatus]"
60 + for (i = 1; i < NSIG; i++) {
61 + if (strncmp(signal_names[i], "SIGJUNK(", 8)
64 + out1fmt("%s\n", signal_names[i] + 3);
68 + signo = atoi(*argptr);
71 + if (0 < signo && signo < NSIG)
72 + out1fmt("%s\n", signal_names[signo] + 3);
74 + error("invalid signal number or exit status: %s",
80 + if (**argptr == '%') {
81 + jp = getjob(*argptr);
82 + if (jp->jobctl == 0)
83 + error("job %s not created under job control",
85 + pid = -jp->ps[0].pid;
87 + pid = atoi(*argptr);
88 + if (kill(pid, signo) != 0)
89 + error("%s: %s", *argptr, strerror(errno));
90 + } while (*++argptr);
100 diff -urN netbsd-sh/jobs.h ash-0.3.7.orig/jobs.h
101 --- netbsd-sh/jobs.h Tue May 23 12:03:19 2000
102 +++ ash-0.3.7.orig/jobs.h Mon Apr 23 22:16:46 2001
104 extern int job_warning; /* user was warned about stopped jobs */
106 void setjobctl __P((int));
107 +int killcmd __P((int, char **));
108 int fgcmd __P((int, char **));
109 int bgcmd __P((int, char **));
110 int jobscmd __P((int, char **));
111 diff -urN netbsd-sh/builtins.def ash-0.3.7.orig/builtins.def
112 --- netbsd-sh/builtins.def Mon Apr 10 13:02:58 2000
113 +++ ash-0.3.7.orig/builtins.def Mon Apr 23 22:16:46 2001
122 diff -urN netbsd-sh/mksignames.c ash-0.3.7.orig/mksignames.c
123 --- netbsd-sh/mksignames.c Thu Jan 1 01:00:00 1970
124 +++ ash-0.3.7.orig/mksignames.c Mon Apr 23 22:16:46 2001
126 +/* signames.c -- Create and write `signames.c', which contains an array of
129 +/* Copyright (C) 1992 Free Software Foundation, Inc.
131 + This file is part of GNU Bash, the Bourne Again SHell.
133 + Bash is free software; you can redistribute it and/or modify it under
134 + the terms of the GNU General Public License as published by the Free
135 + Software Foundation; either version 2, or (at your option) any later
138 + Bash is distributed in the hope that it will be useful, but WITHOUT ANY
139 + WARRANTY; without even the implied warranty of MERCHANTABILITY or
140 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
143 + You should have received a copy of the GNU General Public License along
144 + with Bash; see the file COPYING. If not, write to the Free Software
145 + Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
148 +#include <sys/types.h>
156 +char *signal_names[2 * NSIG];
160 +#if defined (SIGRTMAX) || defined (SIGRTMIN)
166 +initialize_signames ()
169 +#if defined (SIGRTMAX) || defined (SIGRTMIN)
170 + int rtmin, rtmax, rtcnt;
173 + for (i = 1; i < sizeof(signal_names)/sizeof(signal_names[0]); i++)
174 + signal_names[i] = (char *)NULL;
176 + /* `signal' 0 is what we do on exit. */
177 + signal_names[0] = "EXIT";
179 + /* Place signal names which can be aliases for more common signal
180 + names first. This allows (for example) SIGABRT to overwrite SIGLOST. */
182 + /* POSIX 1003.1b-1993 real time signals, but take care of incomplete
183 + implementations. Acoording to the standard, both, SIGRTMIN and
184 + SIGRTMAX must be defined, SIGRTMIN must be stricly less than
185 + SIGRTMAX, and the difference must be at least 7, that is, there
186 + must be at least eight distinct real time signals. */
188 + /* The generated signal names are SIGRTMIN, SIGRTMIN+1, ...,
189 + SIGRTMIN+x, SIGRTMAX-x, ..., SIGRTMAX-1, SIGRTMAX. If the number
190 + of RT signals is odd, there is an extra SIGRTMIN+(x+1).
191 + These names are the ones used by ksh and /usr/xpg4/bin/sh on SunOS5. */
193 +#if defined (SIGRTMIN)
195 + signal_names[rtmin] = "SIGRTMIN";
198 +#if defined (SIGRTMAX)
200 + signal_names[rtmax] = "SIGRTMAX";
203 +#if defined (SIGRTMAX) && defined (SIGRTMIN)
206 + rtcnt = (rtmax - rtmin - 1) / 2;
207 + /* croak if there are too many RT signals */
208 + if (rtcnt >= RTLIM/2)
211 + fprintf(stderr, "%s: error: more than %i real time signals, fix `%s'\n",
212 + progname, RTLIM, progname);
215 + for (i = 1; i <= rtcnt; i++)
217 + signal_names[rtmin+i] = (char *)malloc(RTLEN);
218 + sprintf (signal_names[rtmin+i], "SIGRTMIN+%d", i);
219 + signal_names[rtmax-i] = (char *)malloc(RTLEN);
220 + sprintf (signal_names[rtmax-i], "SIGRTMAX-%d", i);
223 + if (rtcnt < RTLIM/2-1 && rtcnt != (rtmax-rtmin)/2)
225 + /* Need an extra RTMIN signal */
226 + signal_names[rtmin+rtcnt+1] = (char *)malloc(RTLEN);
227 + sprintf (signal_names[rtmin+rtcnt+1], "SIGRTMIN+%d", rtcnt+1);
230 +#endif /* SIGRTMIN && SIGRTMAX */
233 +#if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
234 + signal_names[SIGLOST] = "SIGLOST";
237 +#if defined (SIGMSG) /* HFT input data pending */
238 + signal_names[SIGMSG] = "SIGMSG";
241 +#if defined (SIGDANGER) /* system crash imminent */
242 + signal_names[SIGDANGER] = "SIGDANGER";
245 +#if defined (SIGMIGRATE) /* migrate process to another CPU */
246 + signal_names[SIGMIGRATE] = "SIGMIGRATE";
249 +#if defined (SIGPRE) /* programming error */
250 + signal_names[SIGPRE] = "SIGPRE";
253 +#if defined (SIGVIRT) /* AIX virtual time alarm */
254 + signal_names[SIGVIRT] = "SIGVIRT";
257 +#if defined (SIGALRM1) /* m:n condition variables */
258 + signal_names[SIGALRM1] = "SIGALRM1";
261 +#if defined (SIGWAITING) /* m:n scheduling */
262 + signal_names[SIGWAITING] = "SIGWAITING";
265 +#if defined (SIGGRANT) /* HFT monitor mode granted */
266 + signal_names[SIGGRANT] = "SIGGRANT";
269 +#if defined (SIGKAP) /* keep alive poll from native keyboard */
270 + signal_names[SIGKAP] = "SIGKAP";
273 +#if defined (SIGRETRACT) /* HFT monitor mode retracted */
274 + signal_names[SIGRETRACT] = "SIGRETRACT";
277 +#if defined (SIGSOUND) /* HFT sound sequence has completed */
278 + signal_names[SIGSOUND] = "SIGSOUND";
281 +#if defined (SIGSAK) /* Secure Attention Key */
282 + signal_names[SIGSAK] = "SIGSAK";
286 +#if defined (SIGLWP) /* special signal used by thread library */
287 + signal_names[SIGLWP] = "SIGLWP";
290 +#if defined (SIGFREEZE) /* special signal used by CPR */
291 + signal_names[SIGFREEZE] = "SIGFREEZE";
294 +#if defined (SIGTHAW) /* special signal used by CPR */
295 + signal_names[SIGTHAW] = "SIGTHAW";
298 +#if defined (SIGCANCEL) /* thread cancellation signal used by libthread */
299 + signal_names[SIGCANCEL] = "SIGCANCEL";
303 +#if defined (SIGDIL) /* DIL signal (?) */
304 + signal_names[SIGDIL] = "SIGDIL";
308 +#if defined (SIGCLD) /* Like SIGCHLD. */
309 + signal_names[SIGCLD] = "SIGCLD";
312 +#if defined (SIGPWR) /* power state indication */
313 + signal_names[SIGPWR] = "SIGPWR";
316 +#if defined (SIGPOLL) /* Pollable event (for streams) */
317 + signal_names[SIGPOLL] = "SIGPOLL";
321 +#if defined (SIGWINDOW)
322 + signal_names[SIGWINDOW] = "SIGWINDOW";
326 +#if defined (SIGHUP) /* hangup */
327 + signal_names[SIGHUP] = "SIGHUP";
330 +#if defined (SIGINT) /* interrupt */
331 + signal_names[SIGINT] = "SIGINT";
334 +#if defined (SIGQUIT) /* quit */
335 + signal_names[SIGQUIT] = "SIGQUIT";
338 +#if defined (SIGILL) /* illegal instruction (not reset when caught) */
339 + signal_names[SIGILL] = "SIGILL";
342 +#if defined (SIGTRAP) /* trace trap (not reset when caught) */
343 + signal_names[SIGTRAP] = "SIGTRAP";
346 +#if defined (SIGIOT) /* IOT instruction */
347 + signal_names[SIGIOT] = "SIGIOT";
350 +#if defined (SIGABRT) /* Cause current process to dump core. */
351 + signal_names[SIGABRT] = "SIGABRT";
354 +#if defined (SIGEMT) /* EMT instruction */
355 + signal_names[SIGEMT] = "SIGEMT";
358 +#if defined (SIGFPE) /* floating point exception */
359 + signal_names[SIGFPE] = "SIGFPE";
362 +#if defined (SIGKILL) /* kill (cannot be caught or ignored) */
363 + signal_names[SIGKILL] = "SIGKILL";
366 +#if defined (SIGBUS) /* bus error */
367 + signal_names[SIGBUS] = "SIGBUS";
370 +#if defined (SIGSEGV) /* segmentation violation */
371 + signal_names[SIGSEGV] = "SIGSEGV";
374 +#if defined (SIGSYS) /* bad argument to system call */
375 + signal_names[SIGSYS] = "SIGSYS";
378 +#if defined (SIGPIPE) /* write on a pipe with no one to read it */
379 + signal_names[SIGPIPE] = "SIGPIPE";
382 +#if defined (SIGALRM) /* alarm clock */
383 + signal_names[SIGALRM] = "SIGALRM";
386 +#if defined (SIGTERM) /* software termination signal from kill */
387 + signal_names[SIGTERM] = "SIGTERM";
390 +#if defined (SIGURG) /* urgent condition on IO channel */
391 + signal_names[SIGURG] = "SIGURG";
394 +#if defined (SIGSTOP) /* sendable stop signal not from tty */
395 + signal_names[SIGSTOP] = "SIGSTOP";
398 +#if defined (SIGTSTP) /* stop signal from tty */
399 + signal_names[SIGTSTP] = "SIGTSTP";
402 +#if defined (SIGCONT) /* continue a stopped process */
403 + signal_names[SIGCONT] = "SIGCONT";
406 +#if defined (SIGCHLD) /* to parent on child stop or exit */
407 + signal_names[SIGCHLD] = "SIGCHLD";
410 +#if defined (SIGTTIN) /* to readers pgrp upon background tty read */
411 + signal_names[SIGTTIN] = "SIGTTIN";
414 +#if defined (SIGTTOU) /* like TTIN for output if (tp->t_local<OSTOP) */
415 + signal_names[SIGTTOU] = "SIGTTOU";
418 +#if defined (SIGIO) /* input/output possible signal */
419 + signal_names[SIGIO] = "SIGIO";
422 +#if defined (SIGXCPU) /* exceeded CPU time limit */
423 + signal_names[SIGXCPU] = "SIGXCPU";
426 +#if defined (SIGXFSZ) /* exceeded file size limit */
427 + signal_names[SIGXFSZ] = "SIGXFSZ";
430 +#if defined (SIGVTALRM) /* virtual time alarm */
431 + signal_names[SIGVTALRM] = "SIGVTALRM";
434 +#if defined (SIGPROF) /* profiling time alarm */
435 + signal_names[SIGPROF] = "SIGPROF";
438 +#if defined (SIGWINCH) /* window changed */
439 + signal_names[SIGWINCH] = "SIGWINCH";
443 +#if defined (SIGINFO) && !defined (_SEQUENT_) /* information request */
444 + signal_names[SIGINFO] = "SIGINFO";
447 +#if defined (SIGUSR1) /* user defined signal 1 */
448 + signal_names[SIGUSR1] = "SIGUSR1";
451 +#if defined (SIGUSR2) /* user defined signal 2 */
452 + signal_names[SIGUSR2] = "SIGUSR2";
455 +#if defined (SIGKILLTHR) /* BeOS: Kill Thread */
456 + signal_names[SIGKILLTHR] = "SIGKILLTHR";
459 + for (i = 0; i < NSIG; i++)
460 + if (signal_names[i] == (char *)NULL)
462 + signal_names[i] = (char *)malloc (18);
463 + sprintf (signal_names[i], "SIGJUNK(%d)", i);
466 + signal_names[NSIG] = "DEBUG";
470 +write_signames (stream)
475 + fprintf (stream, "/* This file was automatically created by %s.\n",
477 + fprintf (stream, " Do not edit. Edit support/mksignames.c instead. */\n\n");
478 + fprintf (stream, "#include <signal.h>\n\n");
480 + "/* A translation list so we can be polite to our users. */\n");
481 + fprintf (stream, "char *signal_names[NSIG + 2] = {\n");
483 + for (i = 0; i <= NSIG; i++)
484 + fprintf (stream, " \"%s\",\n", signal_names[i]);
486 + fprintf (stream, " (char *)0x0,\n");
487 + fprintf (stream, "};\n");
498 + progname = argv[0];
502 + stream_name = "signames.c";
504 + else if (argc == 2)
506 + stream_name = argv[1];
510 + fprintf (stderr, "Usage: %s [output-file]\n", progname);
514 + stream = fopen (stream_name, "w");
517 + fprintf (stderr, "%s: %s: cannot open for writing\n",
518 + progname, stream_name);
522 + initialize_signames ();
523 + write_signames (stream);
526 diff -urN netbsd-sh/trap.c ash-0.3.7.orig/trap.c
527 --- netbsd-sh/trap.c Tue May 23 12:03:19 2000
528 +++ ash-0.3.7.orig/trap.c Mon Apr 23 22:16:46 2001
530 char gotsig[NSIG]; /* indicates specified signal received */
531 int pendingsigs; /* indicates some signal received */
533 -static int getsigaction __P((int, sig_t *));
534 +extern char *signal_names[];
538 @@ -107,16 +111,20 @@
542 - if (is_number(*ap))
548 - if ((signo = number(*ap)) < 0 || signo > NSIG)
549 + if ((signo = decode_signal(*ap)) < 0)
550 error("%s: bad trap", *ap);
553 - action = savestr(action);
555 + if (action[0] == '-' && action[1] == '\0')
558 + action = savestr(action);
562 trap[signo] = action;
563 @@ -157,13 +165,13 @@
564 * out what it should be set to.
573 - sig_t sigact = SIG_DFL;
575 + struct sigaction act;
577 if ((t = trap[signo]) == NULL)
579 @@ -206,15 +214,15 @@
581 * current setting unknown
583 - if (!getsigaction(signo, &sigact)) {
584 + if (sigaction(signo, 0, &act) == -1) {
586 * Pretend it worked; maybe we should give a warning
587 * here, but other shells don't. We don't alter
588 * sigmode, so that we retry every time.
593 - if (sigact == SIG_IGN) {
594 + if (act.sa_handler == SIG_IGN) {
595 if (mflag && (signo == SIGTSTP ||
596 signo == SIGTTIN || signo == SIGTTOU)) {
597 *t = S_IGN; /* don't hard ignore these */
598 @@ -225,31 +233,21 @@
601 if (*t == S_HARD_IGN || *t == action)
605 - case S_DFL: sigact = SIG_DFL; break;
606 - case S_CATCH: sigact = onsig; break;
607 - case S_IGN: sigact = SIG_IGN; break;
609 + act.sa_handler = onsig;
612 + act.sa_handler = SIG_IGN;
615 + act.sa_handler = SIG_DFL;
618 - siginterrupt(signo, 1);
619 - return (long)signal(signo, sigact);
623 - * Return the current setting for sig w/o changing it.
626 -getsigaction(signo, sigact)
630 - struct sigaction sa;
632 - if (sigaction(signo, (struct sigaction *)0, &sa) == -1)
634 - *sigact = (sig_t) sa.sa_handler;
637 + sigemptyset(&act.sa_mask);
638 + sigaction(signo, &act, 0);
648 +int decode_signal(const char *string)
652 + if (is_number(string)) return atoi(string);
654 + for (signo=0; signo < NSIG; signo++)
655 + if (strcasecmp(string, signal_names[signo]) == 0 ||
656 + strcasecmp(string, &(signal_names[signo])[3]) == 0)
661 diff -urN netbsd-sh/trap.h ash-0.3.7.orig/trap.h
662 --- netbsd-sh/trap.h Tue May 23 12:03:19 2000
663 +++ ash-0.3.7.orig/trap.h Mon Apr 23 22:16:46 2001
666 int trapcmd __P((int, char **));
667 void clear_traps __P((void));
668 -long setsignal __P((int));
669 +void setsignal __P((int));
670 void ignoresig __P((int));
671 void onsig __P((int));
672 void dotrap __P((void));
673 void setinteractive __P((int));
674 void exitshell __P((int)) __attribute__((noreturn));
675 +int decode_signal __P((const char *));