don't free other jobs when we are specifically using the wait built-in.
This commit is contained in:
parent
271febebf6
commit
97f12feac9
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: jobs.c,v 1.67 2008/12/21 00:19:59 christos Exp $ */
|
||||
/* $NetBSD: jobs.c,v 1.68 2008/12/21 17:16:11 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.67 2008/12/21 00:19:59 christos Exp $");
|
||||
__RCSID("$NetBSD: jobs.c,v 1.68 2008/12/21 17:16:11 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -95,6 +95,8 @@ STATIC void restartjob(struct job *);
|
||||
STATIC void freejob(struct job *);
|
||||
STATIC struct job *getjob(const char *, int);
|
||||
STATIC int dowait(int, struct job *);
|
||||
#define WBLOCK 1
|
||||
#define WNOFREE 2
|
||||
STATIC int waitproc(int, struct job *, int *);
|
||||
STATIC void cmdtxt(union node *);
|
||||
STATIC void cmdlist(union node *, int);
|
||||
@ -615,7 +617,7 @@ waitcmd(int argc, char **argv)
|
||||
jp++;
|
||||
continue;
|
||||
}
|
||||
if (dowait(1, NULL) == -1)
|
||||
if (dowait(WBLOCK, NULL) == -1)
|
||||
return 128 + SIGINT;
|
||||
jp = jobtab;
|
||||
}
|
||||
@ -630,7 +632,7 @@ waitcmd(int argc, char **argv)
|
||||
}
|
||||
/* loop until process terminated or stopped */
|
||||
while (job->state == JOBRUNNING) {
|
||||
if (dowait(1, job) == -1)
|
||||
if (dowait(WBLOCK|WNOFREE, job) == -1)
|
||||
return 128 + SIGINT;
|
||||
}
|
||||
status = job->ps[job->nprocs - 1].status;
|
||||
@ -980,7 +982,7 @@ waitforjob(struct job *jp)
|
||||
INTOFF;
|
||||
TRACE(("waitforjob(%%%d) called\n", jp - jobtab + 1));
|
||||
while (jp->state == JOBRUNNING) {
|
||||
dowait(1, jp);
|
||||
dowait(WBLOCK, jp);
|
||||
}
|
||||
#if JOBS
|
||||
if (jp->jobctl) {
|
||||
@ -1030,7 +1032,7 @@ waitforjob(struct job *jp)
|
||||
*/
|
||||
|
||||
STATIC int
|
||||
dowait(int block, struct job *job)
|
||||
dowait(int flags, struct job *job)
|
||||
{
|
||||
int pid;
|
||||
int status;
|
||||
@ -1041,9 +1043,9 @@ dowait(int block, struct job *job)
|
||||
int stopped;
|
||||
extern volatile char gotsig[];
|
||||
|
||||
TRACE(("dowait(%d) called\n", block));
|
||||
TRACE(("dowait(%x) called\n", flags));
|
||||
do {
|
||||
pid = waitproc(block, job, &status);
|
||||
pid = waitproc(flags & WBLOCK, job, &status);
|
||||
TRACE(("wait returns pid %d, status %d\n", pid, status));
|
||||
} while (pid == -1 && errno == EINTR && gotsig[SIGINT - 1] == 0);
|
||||
if (pid <= 0)
|
||||
@ -1085,7 +1087,8 @@ dowait(int block, struct job *job)
|
||||
int mode = 0;
|
||||
if (!rootshell || !iflag)
|
||||
mode = SHOW_SIGNALLED;
|
||||
if (job != thisjob)
|
||||
if ((job == thisjob && (flags & WNOFREE) == 0) ||
|
||||
(job != thisjob && (flags & WNOFREE) != 0))
|
||||
mode = SHOW_SIGNALLED | SHOW_NO_FREE;
|
||||
if (mode)
|
||||
showjob(out2, thisjob, mode);
|
||||
|
Loading…
Reference in New Issue
Block a user