Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-17116

gracefull job termination

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: In Review (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: core
    • Labels:
      None
    • Environment:
      any
    • Similar Issues:

      Description

      Using the freestyle projects to execute bash shell scripts work fine. But cancelling a jenkins job seems to use SIGKILL. In this way the script cannot perform cleanup operations and free resources.

      SIGKILL cannot be handled by shell

      SIGINT/SIGTERM are not used by jenkins

      Preferred: SIGINT -> wait 5 seconds -> SIGKILL

        Attachments

          Issue Links

            Activity

            Show
            hashar Antoine Musso added a comment - The merge https://github.com/jenkinsci/jenkins/commit/d8eac92ee9a1c19bf145763589f1c152607bf3ed is in tag jenkins-2.141
            Hide
            deepchip Martin d'Anjou added a comment - - edited

            With Jenkins 2.141, I ran the bash script, and the python script and there is no change. Jenkins still leaks processes, and still the signals are not trapped by the user script. The is one difference though, the first click on the terminate button (the red [x]) does not kill the job immediately, but that seems to change nothing.

            Show
            deepchip Martin d'Anjou added a comment - - edited With Jenkins 2.141, I ran the bash script , and the python script and there is no change. Jenkins still leaks processes, and still the signals are not trapped by the user script. The is one difference though, the first click on the terminate button (the red  [x] ) does not kill the job immediately, but that seems to change nothing.
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            Martin d'Anjou Leaking of processes is unrelated to this fix.

            Usual causes:

            • You use 32bit-Java on a 64bit machine
            • You use tool wrappers like Cygwin which mess up the process tree in Windows (See the Cygwin Process Killer plugin)
            • The processes are spawned without inheriting Build reference variables, so the library cannot pick them up if parent processes are already aborted, and the process is orphaned

            I suggest creating a separate issue if none of the above is your case

             

             

             

            Show
            oleg_nenashev Oleg Nenashev added a comment - Martin d'Anjou Leaking of processes is unrelated to this fix. Usual causes: You use 32bit-Java on a 64bit machine You use tool wrappers like Cygwin which mess up the process tree in Windows (See the Cygwin Process Killer plugin) The processes are spawned without inheriting Build reference variables, so the library cannot pick them up if parent processes are already aborted, and the process is orphaned I suggest creating a separate issue if none of the above is your case      
            Hide
            vmagana Victor Magana added a comment -

            Hello, I'm seeing an error in the hudson.util.ProcessTree logger, "External Ctrl+C execution failed for process pid=3872. Ctrl+C process exited with code -1073741515: Failed to attach to the console".  Is there any option/parameter that needs to be set for this to attach and send the Ctrl+C signal. I'm running Jenkins Server on Windows 7x64 version 2.150. Running a Windows batch job on the local master that executes a python script.  Also ran as Execute Python Script job, same error.  Thanks for any help.

             

            Failed to send CTRL+C to pid=3872
            org.jvnet.winp.WinpException: External Ctrl+C execution failed for process pid=3872. Ctrl+C process exited with code -1073741515: Failed to attach to the console (see the AttachConsole WinAPI call). error=0 at winp.cpp:59

            at org.jvnet.winp.Native.sendCtrlC(Native Method)
            at org.jvnet.winp.Native.sendCtrlC(Native.java:90)
            at org.jvnet.winp.WinProcess.sendCtrlC(WinProcess.java:93)
            at hudson.util.ProcessTree$WindowsOSProcess.killSoftly(ProcessTree.java:538)
            at hudson.util.ProcessTree$WindowsOSProcess.killRecursively(ProcessTree.java:517)
            at hudson.util.ProcessTree.killAll(ProcessTree.java:168)
            at hudson.Proc$LocalProc.destroy(Proc.java:384)
            at hudson.Proc$LocalProc.join(Proc.java:357)
            at hudson.tasks.CommandInterpreter.join(CommandInterpreter.java:155)
            at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
            at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
            at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
            at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
            at hudson.model.Build$BuildExecution.build(Build.java:206)
            at hudson.model.Build$BuildExecution.doRun(Build.java:163)
            at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
            at hudson.model.Run.execute(Run.java:1810)
            at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
            at hudson.model.ResourceController.execute(ResourceController.java:97)
            at hudson.model.Executor.run(Executor.java:429)

            Show
            vmagana Victor Magana added a comment - Hello, I'm seeing an error in the hudson.util.ProcessTree logger, "External Ctrl+C execution failed for process pid=3872. Ctrl+C process exited with code -1073741515: Failed to attach to the console".  Is there any option/parameter that needs to be set for this to attach and send the Ctrl+C signal. I'm running Jenkins Server on Windows 7x64 version 2.150. Running a Windows batch job on the local master that executes a python script.  Also ran as Execute Python Script job, same error.  Thanks for any help.   Failed to send CTRL+C to pid=3872 org.jvnet.winp.WinpException: External Ctrl+C execution failed for process pid=3872. Ctrl+C process exited with code -1073741515: Failed to attach to the console (see the AttachConsole WinAPI call). error=0 at winp.cpp:59 at org.jvnet.winp.Native.sendCtrlC(Native Method) at org.jvnet.winp.Native.sendCtrlC(Native.java:90) at org.jvnet.winp.WinProcess.sendCtrlC(WinProcess.java:93) at hudson.util.ProcessTree$WindowsOSProcess.killSoftly(ProcessTree.java:538) at hudson.util.ProcessTree$WindowsOSProcess.killRecursively(ProcessTree.java:517) at hudson.util.ProcessTree.killAll(ProcessTree.java:168) at hudson.Proc$LocalProc.destroy(Proc.java:384) at hudson.Proc$LocalProc.join(Proc.java:357) at hudson.tasks.CommandInterpreter.join(CommandInterpreter.java:155) at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109) at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) at hudson.model.Run.execute(Run.java:1810) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429)
            Hide
            deepchip Martin d'Anjou added a comment - - edited

            The TERM signal is trapped by the freestyle script when the job runs on the Jenkins master, but when it runs on a node, the signal is not received (or not sent?).

            Show
            deepchip Martin d'Anjou added a comment - - edited The TERM signal is trapped by the freestyle script when the job runs on the Jenkins master, but when it runs on a node, the signal is not received (or not sent?).

              People

              • Assignee:
                robinjarry Robin Jarry
                Reporter:
                markusb Markus Breuer
              • Votes:
                36 Vote for this issue
                Watchers:
                48 Start watching this issue

                Dates

                • Created:
                  Updated: