mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-11-06 01:13:39 +01:00
On Windows, `ctrld stop` in Intercept mode sometimes ended with SCM event 7031 and an automatic restart, which put the NRPT catch-all back (#652). Service Stop closes stopCh and returns; kardianos/service then reports SERVICE_STOPPED from the s.Run goroutine. run() returned as soon as finishRun completed, and main called os.Exit(0) right away. If that beat s.Run, the process was gone while the service was still StopPending, and SCM treated it as a crash. The ordering race is older, which fits #492. 9ad42622 (#627) moved the control-server Shutdown from finishRun into Stop, so finishRun no longer spends that time before the process exits, and the exit wins far more often. Lab, service-stop-start Intercept: 1.5.8 0/21, 633689c 13/23, 633689c without the early call 0/15. Keep the early control-server stop that #627 needs, and make run() wait, bounded at 5 s, for s.Run to return before the process exits.