'defunct'에 해당되는 글 1건

  1. 2016.02.16 좀비 프로세스 (Zombie Process) 만드는 방법


# cat zombie.c
#include <stdlib.h>
#include <stdio.h>
int main()
{
    pid_t child_pid;
    child_pid = fork();
    if (child_pid > 0) { // parent
        fprintf(stderr, "child : %d\n", child_pid);
        pause();
    } else if (child_pid == 0) { // child will be zombie
        exit(0);
    } else {
        fprintf(stderr, "fork failed\n");
        exit(1);
    }
}

# gcc -o zombie zombie.c
# ./zombie
# ps -ef | grep zombie
root     23930 23815  0 16:22 pts/2    00:00:00 ./zombie
root     23931 23930  0 16:22 pts/2    00:00:00 [zombie] <defunct>



Posted by 알모리
,