diff --git a/zombie.c b/zombie.c new file mode 100644 index 0000000..d85cbab --- /dev/null +++ b/zombie.c @@ -0,0 +1,26 @@ + +//A process which has finished its execution but still has an entry in the process table to report to its parent process is known as a zombie process. +#include +#include +#include + +int main() +{ + // fork() creates child process identical to parent + int pid = fork(); + + // if pid is greater than 0 than it is parent process + // if pid is 0 then it is child process + // if pid is -ve , it means fork() failed to create child process + + // Parent process + if (pid > 0) + sleep(20); + + // Child process + else { + exit(0); + } + + return 0; +}