A way to synchronously shutdown a ManagedProcess
Would it be possible to have a shutdown on ManagedProcess that is not Asynchronous. I want to ensure Supervisor children are dying before I exit, probably a variant where we can decide a Shutdown Timeout?
Thanks , I'll attend to those issues. You're right on both counts.
Btw, the docs in ManagedProcess.hs, ManagedProcess/Server.hs and ManagedProcess/Server/Restricted.hs still refer to terminateHandler. I assume this is meant to be shutdownHandler now.
Also the docs in Client.hs on line 59 say "If responsiveness is important, a better approach might be to send an /exit signal/ with 'Shutdown' as the reason." Should that be 'ExitShutdown' as a reason?
I think your first suggestion is exactly what we need, didn't know why we didn't come up with that.
On further consideration, the code I posted above is the only way to synchronously stop a managed process - admittedly you could use exit pid reason instead of calling shutdown pid but regardless - since monitoring is the only way to detect the process' death. After all, the process can't reply that it is now dead whilst it is still alive, and doing so before it exits would be a potential race: a process replying with "I am finished/stopped" might get stuck trying to exit (or de-prioritised by the RTS scheduler before terminating), at which point any assumption that it has really died - e.g., trying to register some other process with the same name - would fail.