[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I am looking for a way to create a zombie process



> Is there anyone who can give me a simple program or set of commands that
> creates a zombie process? Thanks in advance. 

Here, public domain.

#include <stdio.h>
#include <unistd.h>

int
main()
{
    if (!fork()) {
	/* Child; die. */
	exit(0);
    } else {
	/* Child dies, is zombie for ten seconds. */
	sleep(10);
	/* Reap it. */
	wait();
	/* Now no zombie. */
	sleep(10);
	exit(0);
    }
}
-- 
Shields.