Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh report the signal that wait was interrupted by, which...



details:   https://anonhg.NetBSD.org/src/rev/3dabe3c0102e
branches:  trunk
changeset: 340090:3dabe3c0102e
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Aug 22 12:12:47 2015 +0000

description:
report the signal that wait was interrupted by, which is not always SIGINT
anymore.

diffstat:

 bin/sh/jobs.c |   8 ++++----
 bin/sh/trap.c |  13 +++++++++++--
 bin/sh/trap.h |   3 ++-
 3 files changed, 17 insertions(+), 7 deletions(-)

diffs (85 lines):

diff -r 2d555cbc8c87 -r 3dabe3c0102e bin/sh/jobs.c
--- a/bin/sh/jobs.c     Sat Aug 22 09:55:23 2015 +0000
+++ b/bin/sh/jobs.c     Sat Aug 22 12:12:47 2015 +0000
@@ -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 @@
                                continue;
                        }
                        if (dowait(WBLOCK, NULL) == -1)
-                              return 128 + SIGINT;
+                              return 128 + lastsig();
                        jp = jobtab;
                }
        }
@@ -647,7 +647,7 @@
                /* 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))
diff -r 2d555cbc8c87 -r 3dabe3c0102e bin/sh/trap.c
--- a/bin/sh/trap.c     Sat Aug 22 09:55:23 2015 +0000
+++ b/bin/sh/trap.c     Sat Aug 22 12:12:47 2015 +0000
@@ -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 @@
        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.
diff -r 2d555cbc8c87 -r 3dabe3c0102e bin/sh/trap.h
--- a/bin/sh/trap.h     Sat Aug 22 09:55:23 2015 +0000
+++ b/bin/sh/trap.h     Sat Aug 22 12:12:47 2015 +0000
@@ -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 dotrap(void);
 void setinteractive(int);
 void exitshell(int) __dead;
+int lastsig(void);



Home | Main Index | Thread Index | Old Index