Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-524

Forked Process not terminated if maven process aborted. Provide means to clean up.



    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.3
    • 2.19
    • process forking
    • None
    • Windows XP, JDK 6
    • Patch


      Steps to reproduce:

      forkMode = once
      Run a test suite containing: Thread.sleep(Integer.MAX_VALUE)
      Kill maven build
      Observe that surefire JVM still running.

      Use Case:

      1. Maven build on Contiunous Integration server forks a JVM to run long test suite.
      2. User aborts the build.
      3. User expects the test suite to be aborted.


      • use forkMode=never

      This is a hassle for us – at best we have to log in remotely to the build server, find the process and kill it. At worst, we waste time misdiagnosing failures in the subsequently triggered build that are due to concurrent tests executing.

      I'm not sure what the expected behaviour is for maven / surefire currently in this situation.

      It is likely that is platform dependent. Windows is different from Unix in the way it kills child processes. [1]

      One solution would be to open up a TCP port on the forked JVM to enable a remote shutdown. This would integrate well with the Hudson Port Allocator plugin [2]. At the conclusion of an aborted build, Hudson would clean up the forked surefire JVM. Perhaps surefire itself could register a shutdown hook in the maven JVM which would use attempt a remote shutdown of the forked JVM?

      I've attached a patch to demonstrate the idea. If you would like to include this functionality, I could clean it up and add test cases.

      [1] http://darkforge.blogspot.com/2007/09/windows-killableprocess-and-case-of.html
      [2] http://weblogs.java.net/blog/kohsuke/archive/2007/11/hudson_portallo.html



        1. surefire-2.4.3-remote-shutdown.patch
          14 kB
          Jason Zaugg
        2. surefire-2.4.3-remote-shutdown.patch
          20 kB
          Jason Zaugg

        Issue Links



              tibordigana Tibor Digana
              retronym Jason Zaugg
              6 Vote for this issue
              12 Start watching this issue