Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bash): improve bash last line as result reliability using bash process substitution #5321

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions backend/windmill-worker/src/bash_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,9 @@ cleanup() {{
# Trap SIGTERM (or other signals) and call cleanup function
trap cleanup SIGTERM SIGINT

# Create a named pipe
mkfifo bp

# Start background processes
cat bp | tail -1 >> ./result2.out &

# Run main.sh in the same process group
{bash} ./main.sh "$@" 2>&1 | tee bp &
{bash} ./main.sh "$@" 2>&1 | tee >(tail -1 >> ./result2.out) &

pid=$!

Expand All @@ -121,7 +116,6 @@ wait $pid
exit_status=$?

# Clean up the named pipe and background processes
rm -f bp
pkill -P $$ || true

# Exit with the captured status
Expand Down Expand Up @@ -624,7 +618,7 @@ $env:PSModulePath = \"{};$PSModulePathBackup\"",
write_file(
job_dir,
"wrapper.sh",
&format!("set -o pipefail\nset -e\nmkfifo bp\ncat bp | tail -1 > ./result2.out &\n{} -F ./main.ps1 \"$@\" 2>&1 | tee bp\nwait $!", POWERSHELL_PATH.as_str()),
&format!("set -o pipefail\nset -e\n{} -F ./main.ps1 \"$@\" 2>&1 | tee >(tail -1 >> ./result2.out) &\nwait $!", POWERSHELL_PATH.as_str()),
)?;

#[cfg(windows)]
Expand Down