I am trying to create a zombie process by understanding online solutions
but still I can't find any zombie process using the following code
I don't know what went wrong in my code
I am trying pstree -p
and top
command to find my zombie process
but I can't find any
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
pid_t childPID;
childPID = fork();
if(childPID < 0)
{
printf("child Process creation failed\n");
}
else if(childPID == 0)
{
printf("I am child Process.My pid is: %d\n", getpid());
exit(0);
sleep(100);
}
else
{
sleep(10);
printf("I am parent process.my pid: %d\n", getpid());
printf("My child process is: %d\n",childPID);
}
return 0;
}