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

            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?).
            Hide
            osmith42 Oliver Smith added a comment -

            I have created the following demo script:

            #!/bin/sh -ex
            
            trap cleanup "TERM"
            set +x
            
            cleanup() {
            	echo "Caught signal, cleaning up..."
            	exit 1
            }
            
            echo "Sleeping..."
            
            while true; do
            	sleep 0.1
            done
            
            # should not get here due to while true
            echo "EOF"
            

            When running in a terminal without jenkins, it catches the signal as expected (e.g. with "pkill -TERM trapscript.sh"):

            $ ./trapscript.sh
            + trap cleanup TERM
            + set +x
            Sleeping...
            Caught signal, cleaning up...
            

            On Jenkins 2.150.2, it does not run the cleanup function:

            [TEST_trap_in_jenkins_job] $ /bin/sh -ex /tmp/jenkins5365212366501463498.sh
            + trap cleanup TERM
            + set +x
            Sleeping...
            Build was aborted
            Aborted by Oliver Smith
            Terminated
            Finished: ABORTED
            

            The server is configured to run all jobs on nodes, so this might be the same problem that Martin d'Anjou pointed out above:
            when it runs on a node, the signal is not received (or not sent?).

            It would be great if somebody could look into this, thanks!

            Show
            osmith42 Oliver Smith added a comment - I have created the following demo script: #!/bin/sh -ex trap cleanup "TERM" set +x cleanup() { echo "Caught signal, cleaning up..." exit 1 } echo "Sleeping..." while true; do sleep 0.1 done # should not get here due to while true echo "EOF" When running in a terminal without jenkins, it catches the signal as expected (e.g. with "pkill -TERM trapscript.sh"): $ ./trapscript.sh + trap cleanup TERM + set +x Sleeping... Caught signal, cleaning up... On Jenkins 2.150.2 , it does not run the cleanup function: [TEST_trap_in_jenkins_job] $ /bin/sh -ex /tmp/jenkins5365212366501463498.sh + trap cleanup TERM + set +x Sleeping... Build was aborted Aborted by Oliver Smith Terminated Finished: ABORTED The server is configured to run all jobs on nodes, so this might be the same problem that Martin d'Anjou pointed out above: when it runs on a node, the signal is not received (or not sent?). It would be great if somebody could look into this, thanks!
            Hide
            deepchip Martin d'Anjou added a comment -

            Pham Vu Tuan do you know how we could debug the communication between master and agents? It seems like the unix kill signal is not sent or received by the agent.

            Show
            deepchip Martin d'Anjou added a comment - Pham Vu Tuan do you know how we could debug the communication between master and agents? It seems like the unix kill signal is not sent or received by the agent.
            Hide
            owenmehegan Owen Mehegan added a comment -

            Martin d'Anjou possibly a question for Jeff Thompson.

            Show
            owenmehegan Owen Mehegan added a comment - Martin d'Anjou possibly a question for Jeff Thompson .

              People

              • Assignee:
                Unassigned
                Reporter:
                markusb Markus Breuer
              • Votes:
                38 Vote for this issue
                Watchers:
                52 Start watching this issue

                Dates

                • Created:
                  Updated: