Zig's Io.Threaded is Neat

29 points by nickmonad


typesanitizer

Isn't pretending that all syscalls can be canceled a lie? Not all syscalls guarantee that they are interruptible (naively, a user might expect that any long-running syscall may be promptly interrupted). https://stackoverflow.com/questions/14542987/why-doing-i-o-in-linux-is-uninterruptible

Retrying is also not necessarily safe for all syscalls after interruption.

If connect() fails, consider the state of the socket as unspecified. Portable applications should close the socket and create a new one for reconnecting.

https://man7.org/linux/man-pages/man2/connect.2.html

Also, I'm not sure if it'll work OOTB with existing debuggers. Usually debuggers want to be aware of signals/they'll catch them. But you probably don't want your program stopping at every cancelation.

While being traced, the tracee will stop each time a signal is delivered, even if the signal is being ignored.

https://man7.org/linux/man-pages/man2/ptrace.2.html