Skip to content
  • Cyril Brulebois's avatar
    Avoid zombies by reaping all child processes (refs: #14948). · cc86a75f
    Cyril Brulebois authored and intrigeri's avatar intrigeri committed
    IO.popen makes it possible to start a command as a child process but it
    won't automatically reap the subprocess when it exits, leading to many
    zombies when running the automated test suite.
    
    Fix this in several ways depending on the call site:
    
     * Create an intermediary variable to hold the subprocess returned by
       IO.popen, making it possible to read its standard output, but also
       allowing to call its close method afterwards. This is less
       straightforward than a IO.popen().gets call, but allows for
       appropriate clean-up.
    
     * When the subprocess object itself (p) is available, add a "p.close"
       call after killing it through "Process.kill(signal, p.pid)".
    
     * Otherwise, when only the pid of the subprocess is available, call
       "Process.wait(pid)" after killing it.
    cc86a75f