[PATCH] xlat/gen.sh: prevent wait from failling upon PID reuse
Dmitry V. Levin
ldv at altlinux.org
Fri Aug 2 16:38:23 UTC 2019
On Fri, Aug 02, 2019 at 02:57:38PM +0200, Jules Maselbas wrote:
> In some case wait can fail if PID has been already taken by a new process.
> As the return status is not used it might be better to always return true.
>
> Reviewed-by: Yann Sionneau <ysionneau at kalray.eu>
> Signed-off-by: Jules Maselbas <jmaselbas at kalray.eu>
> ---
> xlat/gen.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xlat/gen.sh b/xlat/gen.sh
> index ceb0e8fd..d2dfdc8c 100755
> --- a/xlat/gen.sh
> +++ b/xlat/gen.sh
> @@ -310,7 +310,7 @@ main()
> if [ "${jobs}" -gt "$(( ncpus * 2 ))" ]; then
> read wait_pid rest
> pids="$rest"
> - wait -n 2>/dev/null || wait "$wait_pid"
> + wait -n 2>/dev/null || wait "$wait_pid" || true
> : $(( jobs -= 1 ))
> fi <<- EOF
> $pids
I'm afraid this would break $jobs accounting.
What do you think about an alternative fix, e.g.
diff --git a/xlat/gen.sh b/xlat/gen.sh
index 4d34b15c7..06004de99 100755
--- a/xlat/gen.sh
+++ b/xlat/gen.sh
@@ -344,8 +344,13 @@ main()
if [ "${jobs}" -gt "$(( ncpus * 2 ))" ]; then
read wait_pid rest
pids="$rest"
- wait -n 2>/dev/null || wait "$wait_pid"
- : $(( jobs -= 1 ))
+ if wait -n 2>/dev/null ||
+ wait "$wait_pid" 2>/dev/null; then
+ : $(( jobs -= 1 ))
+ else
+ wait
+ jobs=0
+ fi
fi <<- EOF
$pids
EOF
--
ldv
More information about the Strace-devel
mailing list