summary refs log tree commit diff
path: root/src/jobs.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2020-06-02 23:46:48 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2020-07-08 17:05:35 +1000
commit7249493949314557a5d22f52315713e5f9013e15 (patch)
tree38c20b531ce5cf47de35bff90baad79078540a82 /src/jobs.c
parentRelease 0.5.11. (diff)
downloaddash-7249493949314557a5d22f52315713e5f9013e15.tar.gz
dash-7249493949314557a5d22f52315713e5f9013e15.zip
jobs: Fix waitcmd busy loop
We need to clear gotsigchld in waitproc because it is used as
a loop conditional for the waitcmd case.  Without it waitcmd
may busy loop after a SIGCHLD.

This patch also changes gotsigchld into a volatile sig_atomic_t
to prevent compilers from optimising its accesses away.

Fixes: 6c691b3e5099 ("jobs: Only clear gotsigchld when waiting...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--src/jobs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/jobs.c b/src/jobs.c
index 0926360..d4c13c0 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -1136,7 +1136,6 @@ static int dowait(int block, struct job *jp)
 	rpid = 1;
 
 	do {
-		gotsigchld = 0;
 		pid = waitone(block, jp);
 		rpid &= !!pid;
 
@@ -1176,6 +1175,7 @@ waitproc(int block, int *status)
 #endif
 
 	do {
+		gotsigchld = 0;
 		do
 			err = wait3(status, flags, NULL);
 		while (err < 0 && errno == EINTR);