/* Create a zombie process. This is a slight modification of */ /* testvfork. You'll suspend the program after the child is done */ /* and do a ps to see that the child is now a zombie process. */ #include #include #include main(argc,argv) int argc; char *argv[]; {pid_t IsParent; int Code; FILE *fp; printf("A zombie process will be created\n"); IsParent=fork(); if (IsParent) { /* Why doesn't the next line get printed???? The sleep works */ printf("Parent Resumes! \n"); sleep(5); wait(&Code); sleep(5); fp=fopen("Code","w"); fprintf(fp,"Exit Code: %d\n",Code); fclose(fp); } else { printf("I'm the child. My pid is %d\n",getpid()); printf("Hit ^Z within 5 seconds and then do a 'ps xg'.\n"); printf("The child's pid will have a 'Z' under the status column\n"); exit(4); } }