Wait for and/or kill process grandchildren produced by fork

后端 未结 3 1564
被撕碎了的回忆
被撕碎了的回忆 2020-12-20 05:33

I fork() into process X and Y, afterwards Y forks() again into itself and process Z multiple times.

Now process Y is some kind of \"listene

3条回答
  •  难免孤独
    2020-12-20 05:56

    Your question does a terrific job of making the actual problem hard to understand. Still, I believe I can discern the following: "I want to get rid of the zombies". Well, don't we all.

    There are multiple ways of doing this:

    • Have Y ignore SIGCHLD. forked children will not turn into zombies when they die
    • Have Y periodically reap (wait) for any children

    It's your choice which one you use, but it seems to me the first is what you want.

提交回复
热议问题