I have a working Python script that executes an external command and calls Popen.communicate(). However when I call this script from a C process, it fails in os.waitpid() with “[Errno 10] No child processes”. Why?
This looks like a certain bug in Python, but I’m not using threads.
The C process forks, changes its UID, GID, and calls setsid() and then execle() (with “/bin/sh -c /python/script”).
The problem in my case was that the C process was ignoring
SIGCHLD. Since ignored signals are inherited by a forked process, Python process was ignoring it as well, which madewaitpid()fail.Solution: set signal handlers in the C process after forking to
SIG_DFL, if you’ve ignored any.