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

ProcessTreeKiller doesn't work for cygwin sub-processes

    XMLWordPrintable

Details

    Description

      The ProcessTreeKiller[1] doesn't work for cygwin processes launched from a cygwin process.

      To reproduce:

      • Launch a CMD in a terminal.
      • set AAA=123
      • bash.exe
      • sleep 10000
      • Look sleep up in Process Explorer and notice that it has only 4 environment variables, none of which is AAA.

      This is because cygwin maintains the environment variables in the shared memory space for cygwin.dll: See the bottom of http://cygwin.com/cygwin-ug-net/setup-env.html

      One possible solution might be to have a checkbox that enables a cygwin hack that fires up bash.exe and scans /proc//cwd looking for processes that are in the workspace. Then grabs the /proc//winpid and kills them.

      The downside is this may kill too much (a random user cd'd into the workspace, unlikely a problem since it'll prevent directory deletion anyway) and may miss any processes that cd outside the workspace. But better than nothing.

      Ciao!

      [1] https://wiki.jenkins-ci.org/display/JENKINS/ProcessTreeKiller

      Attachments

        Issue Links

          Activity

            ProcessKiller is an extension point that allows plugins to customize the killing logic, so it's conceivable to have a plugin that implements this logic and kills them.

            In this way, the risk only affects those who benefit from this change.

            kohsuke Kohsuke Kawaguchi added a comment - ProcessKiller is an extension point that allows plugins to customize the killing logic, so it's conceivable to have a plugin that implements this logic and kills them. In this way, the risk only affects those who benefit from this change.

            Another thought was to kill the process tree, but that doesn't work because cygwin, in the example above, unsets the parent for sleep. If sleep ran another process, it would correctly show as a child, though (usually).

            docwhat Christian Höltje added a comment - Another thought was to kill the process tree, but that doesn't work because cygwin, in the example above, unsets the parent for sleep. If sleep ran another process, it would correctly show as a child, though (usually).
            oleg_nenashev Oleg Nenashev added a comment - - edited

            I've implemented a draft of the plugin, which allows to kill Cygwin jobs.
            Plugin URL: https://github.com/jenkinsci/cygwin-process-killer-plugin (needs patch in the Jenkins core and more documentation before release)

            Due to JENKINS-19156, plugin won't work properly in the existing releases.

            oleg_nenashev Oleg Nenashev added a comment - - edited I've implemented a draft of the plugin, which allows to kill Cygwin jobs. Plugin URL: https://github.com/jenkinsci/cygwin-process-killer-plugin (needs patch in the Jenkins core and more documentation before release) Due to JENKINS-19156 , plugin won't work properly in the existing releases.
            oleg_nenashev Oleg Nenashev added a comment -

            Cygwin Process Killer Plugin has been released. More info: https://wiki.jenkins-ci.org/display/JENKINS/Cygwin+Process+Killer+Plugin

            Unfortunately, the current implementation of [Jenkins core/winp] does not allow to get the Windows Process tree, so the termination won't work correctly for all cases.

            oleg_nenashev Oleg Nenashev added a comment - Cygwin Process Killer Plugin has been released. More info: https://wiki.jenkins-ci.org/display/JENKINS/Cygwin+Process+Killer+Plugin Unfortunately, the current implementation of [Jenkins core/winp] does not allow to get the Windows Process tree, so the termination won't work correctly for all cases.
            oleg_nenashev Oleg Nenashev added a comment -

            Modified label

            oleg_nenashev Oleg Nenashev added a comment - Modified label

            People

              oleg_nenashev Oleg Nenashev
              docwhat Christian Höltje
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: