4 ms·
I like the Linus Torvalds' interpretation: that (almost) everything is actually a file descriptor. The few things that are not, like fork() returns, are subject
by epx 8y ago
I like the Linus Torvalds' interpretation: that (almost) everything is actually a file descriptor. The few things that are not, like fork() returns, are subject to criticism (DJB wrote about how fork() should return an fd, I just couldn't find the URL right now.)
- severine 8y agoThis? http://cr.yp.to/docs/selfpipe.html http://cr.yp.to/docs/selfpipe.html > Richard Stevens's 1992 book ``Advanced programming in the UNIX environment'' says that you can't safely mix select() or poll() with SIGCHLD (or other signals). The SIGCHLD might go off while select() is starting, too early to interrupt it, too late to change its timeout. Solution: the self-pipe trick. Maintain a pipe and select for readability on the pipe input. Inside the SIGCHLD handler, write a byte (non-blocking, just in case) to the pipe output. Done. Of course, the Right Thing would be to have fork() return a file descriptor, not a process ID.