开发者

No child processes error ... again

开发者 https://www.devze.com 2023-04-09 04:03 出处:网络
I have a process running (call it main proc if you will) doing something. At some point it forks a process say proc1 that does something else. At some other point proc1 decides it needs a child proces

I have a process running (call it main proc if you will) doing something. At some point it forks a process say proc1 that does something else. At some other point proc1 decides it needs a child process to do some chores, let's call it proc2.

proc2 does it's business or runs in an infinite loop at which point proc1 sends a sigterm signal to its' child proc2. Anyway, either way, proc2 finishes cleanly. While proc2 is doing the necessary stuff proc1 is waiting for proc2 to finish. When waitpid() reports proc2 as finished proc1 sends itself sigterm and exits. At that moment the main process was doing a check with waitpid(pid, WNOHANG) in a loop. When proc1 finishes my waitpid from main process throws an error: *Error in atexit._run_exitfuncs: OSError: [Errno 10] No child processes* and Error in sys.exitfunc:OSErr开发者_StackOverflowor: [Errno 10] No child processes.

From what I learned reading around similar questions there is a problem in handling the SIGCHLD signal. If this is the problem than i am unclear as how to solve it. At the moment I solved this by putting the waitpid() in the main process in a try except block. Are there other ways? any better ways?

If it helps I can add an example that I've been fiddling with replicating the errors. Thank you in advance.

0

精彩评论

暂无评论...
验证码 换一张
取 消