4 ms·
Shouldn't this work? - In the parent, open a pipe. Fork. - Parent closes the write side. Child closes the read side, clears FD_CLOEXEC on it, and execs. - Pa
by sigil 10y ago
Shouldn't this work?
- In the parent, open a pipe. Fork.
- Parent closes the write side. Child closes the read side, clears FD_CLOEXEC on it, and execs.
- Parent does a select(2) on the pipe's read side with the desired timeout. If the child exits before the timeout, the pipe becomes "EOF readable." Either way select(2) returns on or before the timeout.
I get that this trick won't work for imposing timeouts on other syscalls (the author points to mkdir(2)) but isn't that the purvey of an RTOS?
- AstralStorm 10y agoPoll and epoll also work. RTOS should prefer asynchronous calls and lockfree queues instead.
- microcolonel 10y agoThat sounds like a nightmare. I doubt many mortals could do hard realtime on a fully-asynchronous RTOS.