APUE course source code
guowenxue
yesterday 7b55c92f8d1401a93c8fd8e342da271dce742000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*********************************************************************************
 *      Copyright:  (C) 2025 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  zombie.c
 *    Description:  This file is zombie process example.
 *
 *        Version:  1.0.0(10/28/2025)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "10/28/2025 09:51:27 AM"
 *
 ********************************************************************************/
 
#include <stdio.h>
#include <unistd.h>
 
int main(void)
{
    pid_t pid = fork();
 
    if (pid == 0)
    {
        printf("Child process exit\n");
        _exit(0);
    }
    else
    {
        sleep(5);  /* 父进程延迟不回收子进程 */
        printf("Parent process done\n");
    }
 
    return 0;
}