From d7eb7a92cd7511f3a3f8bcd6f9652bd53de75cc5 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 15 Jun 2025 11:32:36 +0000 Subject: bugfix: race condition in forx/forstdin Signed-off-by: Laurent Bercot --- src/execline/forstdin.c | 3 ++- src/execline/forx.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/execline/forstdin.c b/src/execline/forstdin.c index 9ea41bd..c7cfe57 100644 --- a/src/execline/forstdin.c +++ b/src/execline/forstdin.c @@ -107,8 +107,9 @@ int main (int argc, char const **argv) pidinfo.len++ ; while (pidinfo.len >= maxpar) { + unsigned int oldlen = pidinfo.len ; sigsuspend(&emptyset) ; - if (maxpar == 1 && not == el_forx_isok(okcodes, nbc, wait_estatus(pidinfo.wstat))) + if (pidinfo.len < oldlen && maxpar == 1 && not == el_forx_isok(okcodes, nbc, wait_estatus(pidinfo.wstat))) return wait_estatus(pidinfo.wstat) ; } } diff --git a/src/execline/forx.c b/src/execline/forx.c index 07ac4e6..23af73e 100644 --- a/src/execline/forx.c +++ b/src/execline/forx.c @@ -81,8 +81,9 @@ int main (int argc, char const **argv) pidinfo.len++ ; while (pidinfo.len >= maxpar) { + unsigned int oldlen = pidinfo.len ; sigsuspend(&emptyset) ; - if (maxpar == 1 && not == el_forx_isok(okcodes, nbc, wait_estatus(pidinfo.wstat))) + if (pidinfo.len < oldlen && maxpar == 1 && not == el_forx_isok(okcodes, nbc, wait_estatus(pidinfo.wstat))) return wait_estatus(pidinfo.wstat) ; } } -- cgit v1.3.1