Module Name: src
Committed By: christos
Date: Sat Aug 22 12:12:47 UTC 2015
Modified Files:
src/bin/sh: jobs.c trap.c trap.h
Log Message:
report the signal that wait was interrupted by, which is not always SIGINT
anymore.
To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/bin/sh/jobs.c
cvs rdiff -u -r1.36 -r1.37 src/bin/sh/trap.c
cvs rdiff -u -r1.21 -r1.22 src/bin/sh/trap.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.74 src/bin/sh/jobs.c:1.75
--- src/bin/sh/jobs.c:1.74 Sat Aug 22 05:55:23 2015
+++ src/bin/sh/jobs.c Sat Aug 22 08:12:47 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: jobs.c,v 1.74 2015/08/22 09:55:23 christos Exp $ */
+/* $NetBSD: jobs.c,v 1.75 2015/08/22 12:12:47 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: jobs.c,v 1.74 2015/08/22 09:55:23 christos Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.75 2015/08/22 12:12:47 christos Exp $");
#endif
#endif /* not lint */
@@ -632,7 +632,7 @@ waitcmd(int argc, char **argv)
continue;
}
if (dowait(WBLOCK, NULL) == -1)
- return 128 + SIGINT;
+ return 128 + lastsig();
jp = jobtab;
}
}
@@ -647,7 +647,7 @@ waitcmd(int argc, char **argv)
/* loop until process terminated or stopped */
while (job->state == JOBRUNNING) {
if (dowait(WBLOCK|WNOFREE, job) == -1)
- return 128 + SIGINT;
+ return 128 + lastsig();
}
status = job->ps[job->nprocs ? job->nprocs - 1 : 0].status;
if (WIFEXITED(status))
Index: src/bin/sh/trap.c
diff -u src/bin/sh/trap.c:1.36 src/bin/sh/trap.c:1.37
--- src/bin/sh/trap.c:1.36 Sat Aug 22 05:55:23 2015
+++ src/bin/sh/trap.c Sat Aug 22 08:12:47 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.36 2015/08/22 09:55:23 christos Exp $ */
+/* $NetBSD: trap.c,v 1.37 2015/08/22 12:12:47 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
#else
-__RCSID("$NetBSD: trap.c,v 1.36 2015/08/22 09:55:23 christos Exp $");
+__RCSID("$NetBSD: trap.c,v 1.37 2015/08/22 12:12:47 christos Exp $");
#endif
#endif /* not lint */
@@ -421,7 +421,16 @@ done:
pendingsigs = 0;
}
+int
+lastsig(void)
+{
+ int i;
+ for (i = NSIG; i > 0; i--)
+ if (gotsig[i - 1])
+ return i;
+ return SIGINT; /* XXX */
+}
/*
* Controls whether the shell is interactive or not.
Index: src/bin/sh/trap.h
diff -u src/bin/sh/trap.h:1.21 src/bin/sh/trap.h:1.22
--- src/bin/sh/trap.h:1.21 Sat Aug 22 05:55:23 2015
+++ src/bin/sh/trap.h Sat Aug 22 08:12:47 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.h,v 1.21 2015/08/22 09:55:23 christos Exp $ */
+/* $NetBSD: trap.h,v 1.22 2015/08/22 12:12:47 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -43,3 +43,4 @@ void onsig(int);
void dotrap(void);
void setinteractive(int);
void exitshell(int) __dead;
+int lastsig(void);