summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorcracauer <cracauer@FreeBSD.org>1999-04-21 11:52:39 +0000
committercracauer <cracauer@FreeBSD.org>1999-04-21 11:52:39 +0000
commitda2b842fad6cd6feb408c139a13b6da10a8ffbc5 (patch)
tree84a311efb1fdc9d20cd0218f25bee08ff1aa36e0 /bin
parentd9c00667012aae534fe05e09eeff108a46bf3307 (diff)
downloadFreeBSD-src-da2b842fad6cd6feb408c139a13b6da10a8ffbc5.zip
FreeBSD-src-da2b842fad6cd6feb408c139a13b6da10a8ffbc5.tar.gz
Next approach to make loops in interactive interruptable.
PR: bin/9173
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/eval.c11
-rw-r--r--bin/sh/expand.c4
-rw-r--r--bin/sh/jobs.c11
-rw-r--r--bin/sh/jobs.h4
4 files changed, 17 insertions, 13 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 36552c4..7bf92b2 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#endif
static const char rcsid[] =
- "$Id: eval.c,v 1.16 1999/04/01 13:27:35 cracauer Exp $";
+ "$Id: eval.c,v 1.17 1999/04/03 12:55:51 cracauer Exp $";
#endif /* not lint */
#include <signal.h>
@@ -410,7 +410,7 @@ evalsubshell(n, flags)
}
if (! backgnd) {
INTOFF;
- exitstatus = waitforjob(jp);
+ exitstatus = waitforjob(jp, (int *)NULL);
INTON;
}
}
@@ -509,7 +509,7 @@ evalpipe(n)
INTON;
if (n->npipe.backgnd == 0) {
INTOFF;
- exitstatus = waitforjob(jp);
+ exitstatus = waitforjob(jp, (int *)NULL);
TRACE(("evalpipe: job done exit status %d\n", exitstatus));
INTON;
}
@@ -602,6 +602,7 @@ evalcommand(cmd, flags, backcmd)
struct localvar *volatile savelocalvars;
volatile int e;
char *lastarg;
+ int realstatus;
#if __GNUC__
/* Avoid longjmp clobbering */
(void) &argv;
@@ -861,9 +862,9 @@ cmddone:
parent: /* parent process gets here (if we forked) */
if (mode == 0) { /* argument to fork */
INTOFF;
- exitstatus = waitforjob(jp);
+ exitstatus = waitforjob(jp, &realstatus);
INTON;
- if (iflag && loopnest > 0 && WIFSIGNALED(exitstatus)) {
+ if (iflag && loopnest > 0 && WIFSIGNALED(realstatus)) {
evalskip = SKIPBREAK;
skipcount = loopnest;
}
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index 074b32a..67a9c8b 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
#endif
static const char rcsid[] =
- "$Id: expand.c,v 1.25 1999/04/09 15:23:48 tegge Exp $";
+ "$Id: expand.c,v 1.26 1999/04/13 04:13:09 tegge Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -493,7 +493,7 @@ expbackq(cmd, quoted, flag)
if (in.buf)
ckfree(in.buf);
if (in.jp)
- exitstatus = waitforjob(in.jp);
+ exitstatus = waitforjob(in.jp, (int *)NULL);
if (quoted == 0)
recordregion(startloc, dest - stackblock(), 0);
TRACE(("evalbackq: size=%d: \"%.*s\"\n",
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index c08758e..07d7e16 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
- "$Id: jobs.c,v 1.22 1998/08/25 09:33:34 cracauer Exp $";
+ "$Id: jobs.c,v 1.23 1998/09/08 13:16:52 cracauer Exp $";
#endif /* not lint */
#include <fcntl.h>
@@ -213,7 +213,7 @@ fgcmd(argc, argv)
#endif
restartjob(jp);
INTOFF;
- status = waitforjob(jp);
+ status = waitforjob(jp, (int *)NULL);
INTON;
return status;
}
@@ -702,9 +702,10 @@ forkshell(jp, n, mode)
*/
int
-waitforjob(jp)
+waitforjob(jp, origstatus)
struct job *jp;
- {
+ int *origstatus;
+{
#if JOBS
int mypgrp = getpgrp();
#endif
@@ -730,6 +731,8 @@ waitforjob(jp)
curjob = jp - jobtab + 1;
#endif
status = jp->ps[jp->nprocs - 1].status;
+ if (origstatus != NULL)
+ *origstatus = status;
/* convert to 8 bits */
if (WIFEXITED(status))
st = WEXITSTATUS(status);
diff --git a/bin/sh/jobs.h b/bin/sh/jobs.h
index e637eae..4a39df2 100644
--- a/bin/sh/jobs.h
+++ b/bin/sh/jobs.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)jobs.h 8.2 (Berkeley) 5/4/95
- * $Id: jobs.h,v 1.9 1998/09/08 13:16:52 cracauer Exp $
+ * $Id: jobs.h,v 1.10 1998/09/10 22:09:11 cracauer Exp $
*/
/* Mode argument to forkshell. Don't change FORK_FG or FORK_BG. */
@@ -91,7 +91,7 @@ int waitcmd __P((int, char **));
int jobidcmd __P((int, char **));
struct job *makejob __P((union node *, int));
int forkshell __P((struct job *, union node *, int));
-int waitforjob __P((struct job *));
+int waitforjob __P((struct job *, int *));
int stoppedjobs __P((void));
char *commandtext __P((union node *));
OpenPOWER on IntegriCloud