In my example the dash process still exists until both sleeps have been finished. I have written a small testcase in C to check if its an applications fault if there are zombie processes:
This example will cause sh to get a zombie process if echo has finished until the main application finishes. But if I'm uncommenting /*pclose(pipe);*/ the zombie process will successfully clean up. So I'm assuming its the fault of the parent process if there are zombie processes because it isn't closing the related file descriptor.
In my example the dash process still exists until both sleeps have been finished. I have written a small testcase in C to check if its an applications fault if there are zombie processes:
#include <stdio.h>
#include <unistd.h>
int main()
{
FILE *pipe;
if((pipe = popen("echo", "r")) == 0)
{
}
/*pclose(pipe);*/
usleep(100000000);
return 0;
}
This example will cause sh to get a zombie process if echo has finished until the main application finishes. But if I'm uncommenting /*pclose(pipe);*/ the zombie process will successfully clean up. So I'm assuming its the fault of the parent process if there are zombie processes because it isn't closing the related file descriptor.