
Am 10.02.2011 17:11, schrieb Artyom:
Small notes:
1. waitpid should be done for specific pid I waiting for to allow other threads to use wait 2. You need to use WNOHANG so it would not be blocking, and allow to check specific ids.
You would create for each child process you want to wait for a separat thread? Wouldn't this degrade the performance of the system if you have to wait for many processes? Why not using only one thread which handles SIGCHLD and catches all child stati?
So basically such thread need
forever ( sigwait(sigchld) foreach pid in waiting set if(waitpid(pid, WNOHANG) = done) notify io_service remove pid from waiting set }
you iterate over the complete set of pids you are waiting for. why not let waitpid( -1,...) let tell which child has changed its status. Shouldn't the wait-functionality be interrupt-able? How to do a grace full shutdown if forever blocking? Oliver