--- a/mercurial/utils/procutil.py Thu May 07 15:00:33 2020 +0200
+++ b/mercurial/utils/procutil.py Thu May 07 03:14:52 2020 -0700
@@ -16,6 +16,7 @@
import signal
import subprocess
import sys
+import threading
import time
from ..i18n import _
@@ -604,6 +605,14 @@
pid = os.fork()
if pid:
if not ensurestart:
+ # Even though we're not waiting on the child process,
+ # we still must call waitpid() on it at some point so
+ # it's not a zombie/defunct. This is especially relevant for
+ # chg since the parent process won't die anytime soon.
+ # We use a thread to make the overhead tiny.
+ def _do_wait():
+ os.waitpid(pid, 0)
+ threading.Thread(target=_do_wait, daemon=True).start()
return
# Parent process
(_pid, status) = os.waitpid(pid, 0)