문제

Hypothetically, let's say main() function creates second process calling fork() and let's say this new process starts creating its own children by function makeChildren(), one million in loop, crazy user. Fork() fails, makeChildren() returns error. How to get rid off these new processes that have been already created? Can I use killpg(getpgrp(), SIGKILL) ??? If I understand it right each process in this scenario has same group ID, no? When I use killpg(getpgrp(), SIGKILL) program will terminate immediately, am I right? Do I have to use setpgid()? I want to kill this zombies and in main release shared memory, semaphores and so on ... Thank you for any explanation.

도움이 되었습니까?

해결책

If the parent process terminates, its children will be reassigned to the init process. It will wait for them so they shouldn't become zombies.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top