UTop blocks and has to be kill'd -9 after a forked child terminates
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).
Any news?
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.forkbyLwt_unix.fork -
replace
exitby 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