succeeded every time sigaction failed [suggested by mycroft]
SCCS-vsn: bin/sh/trap.c 8.5
SCCS-vsn: bin/sh/trap.h 8.3
-static char sccsid[] = "@(#)trap.c 8.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) %G%";
#endif /* not lint */
#include <signal.h>
#endif /* not lint */
#include <signal.h>
char gotsig[NSIG]; /* indicates specified signal received */
int pendingsigs; /* indicates some signal received */
char gotsig[NSIG]; /* indicates specified signal received */
int pendingsigs; /* indicates some signal received */
+static int getsigaction __P((int, sig_t *));
+
/*
* The trap builtin.
*/
/*
* The trap builtin.
*/
sig_t sigact = SIG_DFL;
char *t;
extern void onsig();
sig_t sigact = SIG_DFL;
char *t;
extern void onsig();
- extern sig_t getsigaction();
if ((t = trap[signo]) == NULL)
action = S_DFL;
if ((t = trap[signo]) == NULL)
action = S_DFL;
- if (signo == SIGKILL)
- /* Pretend it worked */
- return 0;
-
t = &sigmode[signo - 1];
if (*t == 0) {
/*
* current setting unknown
*/
t = &sigmode[signo - 1];
if (*t == 0) {
/*
* current setting unknown
*/
- sigact = getsigaction(signo);
+ if (!getsigaction(signo, &sigact)) {
+ /*
+ * Pretend it worked; maybe we should give a warning
+ * here, but other shells don't. We don't alter
+ * sigmode, so that we retry every time.
+ */
+ return 0;
+ }
if (sigact == SIG_IGN) {
if (mflag && (signo == SIGTSTP ||
signo == SIGTTIN || signo == SIGTTOU)) {
if (sigact == SIG_IGN) {
if (mflag && (signo == SIGTSTP ||
signo == SIGTTIN || signo == SIGTTOU)) {
/*
* Return the current setting for sig w/o changing it.
*/
/*
* Return the current setting for sig w/o changing it.
*/
-sig_t
-getsigaction(signo)
+static int
+getsigaction(signo, sigact)
{
struct sigaction sa;
if (sigaction(signo, (struct sigaction *)0, &sa) == -1)
{
struct sigaction sa;
if (sigaction(signo, (struct sigaction *)0, &sa) == -1)
- error("Sigaction system call failed");
-
- return (sig_t) sa.sa_handler;
+ return 0;
+ *sigact = (sig_t) sa.sa_handler;
+ return 1;
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)trap.h 8.2 (Berkeley) %G%
+ * @(#)trap.h 8.3 (Berkeley) %G%
*/
extern int pendingsigs;
*/
extern int pendingsigs;
int trapcmd __P((int, char **));
void clear_traps __P((void));
long setsignal __P((int));
int trapcmd __P((int, char **));
void clear_traps __P((void));
long setsignal __P((int));
-sig_t getsigaction __P((int));
void ignoresig __P((int));
void onsig __P((int));
void dotrap __P((void));
void ignoresig __P((int));
void onsig __P((int));
void dotrap __P((void));