Oh no, don't Fermat us! I'm curious what this "self pipe trick" looks like.
It's a quite simple process actually.
I obtain file descriptors for both ends of a pipe via, well... pipe: pipe in nix::unistd - Rust.
then, I use a normal sigchld handler (not the signal_hook one; I couldn't figure that out so just gave up) with the sigaction function like I did in the beginning. the sigchld handler does nothing but calls
write, which is async-signal-safe: write in nix::unistd - Rust. It sends a packet with one byte
I spawn a thread with
std::thread::spawn after that which calls read in nix::unistd - Rust in an infinite loop (which is not at all expensive since the function blocks at the kernel level) . Once it does recieve a message, if the message is indeed the ascii byte
. it will execute the real code for the SIGCHLD handler. Of course, in this thread there's no need to worry about async-signal-safeness. Hope this helps someone else!