Skip to content

[JENKINS-75512] Ensure SIGPIPE is not hidden when calling shell script to avoid hanging. #253

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ private List<String> scriptLauncherCmd(ShellController c, FilePath ws, @CheckFor
cmdString = cmdString.replace("$", "$$"); // escape against EnvVars jobEnv in LocalLauncher.launch
List<String> cmd = new ArrayList<>();
if (os != OsType.DARWIN && os != OsType.WINDOWS) { // JENKINS-25848 JENKINS-33708
cmd.add("nohup");
// Some java implementation do block SIGPIPE signal by default, so make sure the default
// signal handler is used to avoid having commands hanging for ever.
// env --default-signal=SIGPIPE was introduced in coreutils 8.31 released in 2019,
// so cope with old OS not supporting this.
cmd.addAll(Arrays.asList("sh", "-c", "if env --default-signal=SIGPIPE true 1>/dev/null 2>&1; then exec env --default-signal=SIGPIPE \"$$@\"; else exec \"$$@\"; fi", "--", "nohup"));
}
if (LAUNCH_DIAGNOSTICS) {
cmd.addAll(Arrays.asList("sh", "-c", cmdString));
Expand Down