From 8bc9a021a88391147c9170f56b5a0edddd55bc7d Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 8 Nov 2024 16:33:01 +0100 Subject: [PATCH] fix(bash): correctly propagate exit errors --- backend/windmill-worker/src/bash_executor.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/windmill-worker/src/bash_executor.rs b/backend/windmill-worker/src/bash_executor.rs index 2c4c46ab7d..2582f98b58 100644 --- a/backend/windmill-worker/src/bash_executor.rs +++ b/backend/windmill-worker/src/bash_executor.rs @@ -89,8 +89,18 @@ cat bp | tail -1 >> ./result2.out & # Run main.sh in the same process group {bash} ./main.sh "$@" 2>&1 | tee bp & -# Wait for all background processes to finish -wait +pid=$! + +# Wait for main.sh to finish and capture its exit status +wait $pid +exit_status=$? + +# Clean up the named pipe and background processes +rm -f bp + + +# Exit with the captured status +exit $exit_status "#, bash = BIN_BASH.as_str(), );