Debian Codegraph @

listings/chapter-3/zombie.c

raw
1 /***********************************************************************
2 * Code listing from "Advanced Linux Programming," by CodeSourcery LLC *
3 * Copyright (C) 2001 by New Riders Publishing *
4 * See COPYRIGHT for license information. *
5 ***********************************************************************/
6
7 #include <stdlib.h>
8 #include <sys/types.h>
9 #include <unistd.h>
10
11 int main ()
12 {
13 pid_t child_pid;
14
15 /* Create a child process. */
16 child_pid = fork ();
17 if (child_pid > 0) {
18 /* This is the parent process. Sleep for a minute. */
19 sleep (60);
20 }
21 else {
22 /* This is the child process. Exit immediately. */
23 exit (0);
24 }
25 return 0;
26 }