Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This makes sure we can process signals in luv the same way we do in uring. As stated in #400 the main issue is that luv's mainloop will restart on EINTR and we will never unwind back to ocaml land, so even though the process got the signal, the runtime will not see it until something else goes on. The trick here is to abuse POSIX thread semantics and shove all signals into one specific systhread by blocking them in the other threads. Additionally, I've fixed a bug in OCaml 5.0 where the systhreads end up starting with all signals blocked: ocaml/ocaml#11880. This PR works even with/without the bug. Danger Zone ~~~~~~~~~~~ This is tricky ! If you're thinking we can do better than pipes, think again ! Unix.sigsuspend doesn't work on multithreaded, we don't have a real Unix.pause (it's implemented on top of sigsuspend !). The semantics for kill(2) to "self" are different than "from outside" when multithreaded, and the runtime doesn't expose pthread_kill(2). That's why on the test we have to fork and signal back to the parent. I know, it's horrible. Co-authored-by: Thomas Leonard <[email protected]>
- Loading branch information