'Zombie'에 해당되는 글 1건

If parent doesn't use 'wait' system call for it's child, that child becomes zombie after end of execution.
(At zombie state, all allocated resources are removed, but it is still in process table for parent to get child's exit status.)
Here is very simple example

main (int argc, char* argv[]) {
    if (fork ()) { /* parent */
    } else { /* child */
    return 0;

In this case, child becomes zombie.
Simplest way to avoid making zombie is get exit status of child by use 'wait' system call at signal handler for SIGCHLD.
The point is, "DO NOT forget about getting child's exit status not to make zombie!"
At above example following codes should be added at [*A]

int status; wait(&status);


블로그 이미지


댓글을 달아 주세요