diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-06-15 11:32:36 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-06-15 11:32:36 +0000 |
| commit | d7eb7a92cd7511f3a3f8bcd6f9652bd53de75cc5 (patch) | |
| tree | 33dba520f9a7a6aab10bbb7bf0fdde504a19cdff | |
| parent | 8f39a307f966f7c426bbfccd08c5f18f3c34fcd2 (diff) | |
| download | execline-d7eb7a92cd7511f3a3f8bcd6f9652bd53de75cc5.tar.gz | |
bugfix: race condition in forx/forstdin
Signed-off-by: Laurent Bercot <ska@appnovation.com>
| -rw-r--r-- | src/execline/forstdin.c | 3 | ||||
| -rw-r--r-- | src/execline/forx.c | 3 |
2 files changed, 4 insertions, 2 deletions
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) ; } } |
