[X-Unix] Zombies

Cloyce D. Spradling cloyce+xunix at headgear.org
Wed Jun 16 14:00:22 PDT 2004


On Wed, Jun 16, 2004 at 03:20:40PM -0500, Gretchen Hayman wrote:
: On Jun 14, 2004, at 18:40, James Bucanek wrote:
: > I don't have any handy way of making a zombie process to test this,
: Ah, now there's a helpful little script someone could write!  :)

Handy-dandy zombie factory (use at your own risk):

----CUT----OW----CUT----OW----CUT----
#include <sys/types.h>
#include <unistd.h>

#define ZOMBIES 2
int main() {
  int i;

  for(i = 0; i < ZOMBIES; i++) {
    if (fork() == 0) {
      /* child */
      exit(0);
    }
  }
  /* if you just exit here, init will reap the zombies */
  sleep(10000);
}
----CUT----OW----CUT----OW----CUT----

--
Cloyce



More information about the X-Unix mailing list