dash: update latest fix.

This commit is contained in:
Leah Neukirchen 2018-05-06 19:20:44 +02:00
parent 384cb0c161
commit 4d10f2b6a3
2 changed files with 55 additions and 7 deletions

View file

@ -1,16 +1,64 @@
Subject: Re: Regression in dash 0.5.10 related to subshells
Message-ID: <20180505160243.t5rujv3eifiust5a@gondor.apana.org.au>
Subject: [PATCH v3] jobs - Do not block when waiting on SIGCHLD
Message-ID: <20180506164034.s6y4n7yt2gianh63@gondor.apana.org.au>
diff --git a/src/eval.c b/src/eval.c
index a27d657..39c4e41 100644
--- src/eval.c
+++ src/eval.c
@@ -859,10 +859,8 @@ bail:
if (!(flags & EV_EXIT) || have_traps()) {
INTOFF;
jp = makejob(cmd, 1);
- if (forkshell(jp, cmd, FORK_FG) != 0) {
- INTON;
+ if (forkshell(jp, cmd, FORK_FG) != 0)
break;
- }
FORCEINTON;
}
listsetvar(varlist.list, VEXPORT|VSTACK);
@@ -875,11 +873,8 @@ bail:
if (execcmd && argc > 1)
listsetvar(varlist.list, VEXPORT);
}
- if (evalbltin(cmdentry.u.cmd, argc, argv, flags)) {
- if (exception == EXERROR && spclbltin <= 0) {
- FORCEINTON;
- break;
- }
+ if (evalbltin(cmdentry.u.cmd, argc, argv, flags) &&
+ !(exception == EXERROR && spclbltin <= 0)) {
raise:
longjmp(handler->loc, 1);
}
@@ -892,6 +887,7 @@ raise:
}
status = waitforjob(jp);
+ FORCEINTON;
out:
if (cmd->ncmd.redirect)
--- src/jobs.c
+++ src/jobs.c
@@ -975,8 +975,8 @@ waitforjob(struct job *jp)
@@ -975,10 +975,17 @@ waitforjob(struct job *jp)
int st;
TRACE(("waitforjob(%%%d) called\n", jp ? jobno(jp) : 0));
- while ((jp && jp->state == JOBRUNNING) || gotsigchld)
- dowait(DOWAIT_BLOCK, jp);
+ while (jp ? jp->state == JOBRUNNING : gotsigchld)
+ dowait(jp ? DOWAIT_BLOCK : DOWAIT_NORMAL, jp);
if (!jp)
- if (!jp)
+ if (!jp) {
+ int pid = gotsigchld;
+
+ while (pid > 0)
+ pid = dowait(DOWAIT_NORMAL, NULL);
+
return exitstatus;
+ }
+
+ while (jp->state == JOBRUNNING)
+ dowait(DOWAIT_BLOCK, jp);
st = getstatus(jp);
#if JOBS
if (jp->jobctl) {

View file

@ -1,7 +1,7 @@
# Template file for 'dash'
pkgname=dash
version=0.5.10
revision=2
revision=3
build_style=gnu-configure
hostmakedepends="bison"
register_shell="/bin/sh /bin/dash"