2010/4/19 marius zbihlei marius.zbihlei@1and1.ro:
Hello Iñaki ,
I had a look over the patches and they look fine. Of course I think one of the core developers should have a look also.
I suggest one thing: Instead of a read() from the read end of the pipe, can we use a select()/poll() so we can have timeouts and prevent blocking. For example does it make sense to say that if the child process doesn't write something to the pipe in let's say 1 minute, this means that it is blocked somewhere and the main process should exit with error (thus the init.d script should return != 0) ?!
Hi, in the proposed code if the child process (main process) exits due to an error then it writes nothing to the pipe and the parent process reads 0 bytes from it. It means that an error has occurred and it exits with -1. In case main process starts properly it writes something to the pipe ("go") so the master process reads 2 bytes (>0) and exits with 0.
In the case you suggest, if the main process gets blocked for some reason (it doesn't exit but neither writes into the pipe) then as you say the parent process would get blocked. Not good. Is it possible to do a blocking read of the pipe with a timeout of 4-5 seconds? or is the select()/poll() stuff required for it?
Anyhow, I wonder if it would be enough. Note that in case the main process gets blocked and the parent process exits with -1 (due to the suggested timeout) the main process still remains running (even if blocked). Perhaps the parent process should kill it and ensure it's dead in case such timeout occurs?
Thanks a lot.