#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
int pid = fork();
if (pid == 0)
{
printf("I am Child\n");
exit(0);
}
printf("I am Parent\n");
while(1);
}
Here is what happens on my Linux when i run this code: zombie process shows up in htop for a second and then just disappears. I tried setting signal handler in parent:
void callback(int signum)
{
return;
}
int main()
{
int pid = fork();
if (pid == 0)
{
printf("I am Child\n");
exit(0);
}
printf("I am Parent\n");
signal(SIGCHLD, callback);
while(1);
}
But nothing changed. Why my zombie process disappears from htop?
P.S.: compiled with no optimization
Update: it doesn't show up in htop but does show up in top. Seems like a bug to me. I vote for deletion of this question.