See cleanup.ml, it calls Lwt_main.run when handling a signal.
I think this is very fragile and could lock up under some situations, reading the Lwt_main.run documentation it says:
Note that you should avoid using run inside threads
The calling threads will not resume before run returns.
Successive invocations of run are serialized: an invocation of run will not terminate before all subsequent invocations are terminated.
So if we get a signal while the main Lwt_main.run is running the one inside the signal handler wouldn't run at all.
Unfortunately the Lwt documentation is not very clear on how to resolve Lwt promises when triggered from a signal handler, but perhaps the right thing to do would be to use Lwt.async (...) (provided we have an exception handler set up for asynchronous exceptions).
See cleanup.ml, it calls Lwt_main.run when handling a signal.
I think this is very fragile and could lock up under some situations, reading the Lwt_main.run documentation it says:
So if we get a signal while the main Lwt_main.run is running the one inside the signal handler wouldn't run at all.
Unfortunately the Lwt documentation is not very clear on how to resolve Lwt promises when triggered from a signal handler, but perhaps the right thing to do would be to use Lwt.async (...) (provided we have an exception handler set up for asynchronous exceptions).