on 01/25/2013 15:31, Mark Wu wrote:
On 01/25/2013 03:20 PM, Mark Wu wrote:
Great work! The default action for SIGCHLD is ignore, so there's no problems reported before a signal handler is installed by zombie reaper. But I still have one problem: the python multiprocessing.manager code is running a new thread and according to the implementation of python's signal, only the main thread can receive the signal. So how is the signal delivered to the server thread?
Is it possible to reap the zombie process in the main thread asynchronously and periodically? It could be more safe than using the signal handler.
It seem add this line
signal.siginterrupt(signal.SIGCHLD, False)
after registering the SIGCHLD handler can solve the problem and pass the unit test in Royce's attachment.
Another idea is to use signalfd. When using a signalfd, the targeted signal is blocked using sigprocmask, then another thread can read the signalfd to get the targeted signal. If the signalfd is created or set to non-blocking mode, we can select/poll on the signalfd for reading. I write code snippet to demo it at
https://gist.github.com/4661516
Firstly yum install python-signalfd. Then run "python signalfdReaper.py" to test the demo code. In this way, SIGCHLD will not lead to interrupted calls since it's blocked.
I think both Python manager and our zombie reaper both should be patched. For Python manager, it should restart interrupted calls. For zombie reaper is should avoid SIGCHLD leading to interrupted calls.