tests/killdaemons.py
changeset 51991 23cc79e04c28
parent 51699 ca7bde5dbafb
child 52640 24ee91ba9aa8
--- a/tests/killdaemons.py	Thu Oct 10 17:55:50 2024 +0200
+++ b/tests/killdaemons.py	Sat Oct 12 15:22:03 2024 -0400
@@ -56,7 +56,12 @@
             if r == WAIT_OBJECT_0:
                 pass  # terminated, but process handle still available
             elif r == WAIT_TIMEOUT:
-                _check(ctypes.windll.kernel32.TerminateProcess(handle, -1))
+                # Allow the caller to optionally specify the exit code, to
+                # simulate killing with a signal.
+                exit_code = int(os.environ.get("DAEMON_EXITCODE", -1))
+                _check(
+                    ctypes.windll.kernel32.TerminateProcess(handle, exit_code)
+                )
             elif r == WAIT_FAILED:
                 _check(0)  # err stored in GetLastError()