Skip to content
Advertisement

Kill child process spawned with execl without making it zombie

I need to spawn a long-running child process and then kill it from the parent code. At the moment I do like this:

JavaScript

This does the job in the sense that the child process is stopped, but then it remains as a zombie. I tried to completely remove it by adding:

JavaScript

to no avail. I must be doing something wrong but I can’t figure out what, so any help would be greatly appreciated. Thanks.

Advertisement

Answer

JavaScript

Presto. No zombie.

By ignoring SIGCHLD we tell the kernel we don’t care about exit codes so the zombies just go away immediately.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement