Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions zombie.c
Original file line number Diff line number Diff line change
@@ -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 <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

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;
}