janestreet / async_unix

Jane Street Capital's asynchronous execution library (unix)
MIT License
33 stars 21 forks source link

Signal.handle terminating #12

Closed vbmithr closed 8 years ago

vbmithr commented 8 years ago

On the new Async working on 4.03.0, my code which was previously using Signal.handle terminating to do some effects is not working anymore, i.e. the code supposed to run on interruption and other termination case is not run anymore.

ghost commented 8 years ago

Can you provide an example that used to work with 113.33 and doesn't work with the development version?

vbmithr commented 8 years ago

On 20/07/2016 08:17, Jérémie Dimino wrote:

Can you provide an example that used to work with 113.33 and doesn't work with the development version?

https://github.com/vbmithr/virtu/blob/master/src/logobs.ml#L87

The handler here seems to never execute. I'm pretty sure this code use to run in the previous version.

Vincent

ghost commented 8 years ago

Could you provide a minimal example that work with 113.33 but not the development version?

vbmithr commented 8 years ago

On 20/07/2016 14:27, Jérémie Dimino wrote:

Could you provide a minimal example that work with 113.33 but not the development version?

I just re-tested. Actually the code is executed. What might have changed is that the log messages are not displayed anymore.

let () =
  set_level `Error;
  Signal.(handle terminating ~f:(fun _signal ->
      error "Terminating";
      Out_channel.(output_string stdout "Terminating.\n");
      Core.Std.exit 0
    )
    );
  never_returns @@ Scheduler.go ()

This prints correctly on stdout but no log is displayed.

Vincent

ghost commented 8 years ago

shouldn't it be Shutdown.exit 0 instead of Core.Std.exit 0 given that you are using async?

vbmithr commented 8 years ago

On 20/07/2016 15:32, Jérémie Dimino wrote:

shouldn't it be |Shutdown.exit 0| instead of |Core.Std.exit 0| given that you are using async?

Possibly. Should I use don't_wait_for @@ Shutdown.exit 0 then? Edit: Ok, got it.