utop icon indicating copy to clipboard operation
utop copied to clipboard

UTop blocks and has to be kill'd -9 after a forked child terminates

Open Armael opened this issue 10 years ago • 2 comments

Not sure this title is the most accurate description of the problem, but after running the following piece of code:

match Unix.fork () with
| 0 -> print_endline "hello"; exit 0
| pid -> Unix.waitpid [] pid

utop blocks; then if I try to hit Control-C, utop completely freezes and I have to kill it by sending SIGKILL (kill -9).

Armael avatar Dec 20 '15 18:12 Armael

Any news?

Armael avatar Feb 08 '16 14:02 Armael

I had a look; this is linked to lwt and some at_exit handler. Currently there are two ways to solve the problem:

  • replace Unix.fork by Lwt_unix.fork

  • replace exit by this external which doesn't run exit handlers:

    external sys_exit : int -> unit = "caml_sys_exit"
    

Unfortunately I don't have a better solution for now. At some point I'm planning to stop using lwt in lambda-term, so that one is free to use lwt, async or something else. That will solve these problems but I haven't had the time to work on this yet

ghost avatar Feb 08 '16 15:02 ghost