I have done more experiments. And I am still not seeing the signal being sent, like Daniel Beck is seeing. I started with this Java version:
- Java1.8.0_77. OS is Fedora release 14 (Laughlin).
The Jenkins console shows:
[freestyle-kill] $ /bin/sh -xe /tmp/hudson3073245061937599649.sh
+ trap 'echo TERM >terminated.txt' TERM
+ sleep 120
Build was aborted
Aborted by martinda
Finished: ABORTED
Observe that the script is not printing "TERM" to the file, like it does in Daniel's environment. I also tried these Java versions ones:
- Java OpenJDK 1.8.0_111, Red Hat Enterprise Linux Server release 6.6 (Santiago)
- Java HotSpot 1.8.0_121, Ubuntu 16.04 LTS (Xenial Xerus)
- Java OpenJDK 1.8.0_121, Ubuntu 16.04 LTS (Xenial Xerus)
I captured some logs using OpenJDK 1.8.0_121 on Ubuntu 16.04. In the terminal running Jenkins:
INFO: jenkins-17116/freestyle #4 aborted
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at java.lang.UNIXProcess.waitFor(UNIXProcess.java:395)
at hudson.Proc$LocalProc.join(Proc.java:318)
at hudson.tasks.CommandInterpreter.join(CommandInterpreter.java:135)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:95)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:64)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1720)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
In the jenkins log recorder:
Feb 07, 2017 9:42:11 AM FINE hudson.util.ProcessTree
killAll: process=java.lang.UNIXProcess@2a8af379 and envs={HUDSON_COOKIE=2d16a893-7e22-4360-aad0-0931104599a5}
Feb 07, 2017 9:42:11 AM FINE hudson.util.ProcessTree
Recursively killing pid=25054
Feb 07, 2017 9:42:11 AM FINE hudson.util.ProcessTree
Recursively killing pid=25055
Feb 07, 2017 9:42:11 AM FINE hudson.util.ProcessTree
Killing pid=25055
Feb 07, 2017 9:42:11 AM FINE hudson.util.ProcessTree
Killing pid=25054
None of them traps the signal. |