부모는 자식을 기다리고 종료 상태를 읽어야합니다. "사람이 대기"에서 : 부모가 아직 살아 있다면 기본적으로
A child that terminates, but has not been waited for becomes a "zombie".
The kernel maintains a minimal set of information about the zombie process (PID,
termination status, resource usage information) in order to allow the parent to later
perform a wait to obtain information about the child. As long as a zombie is not
removed from the system via a wait, it will consume a slot in the kernel process
table, and if this table fills, it will not be possible to create further
processes.
If a parent process terminates, then its "zombie" children (if any) are adopted by
init(8), which automatically performs a wait to remove the zombies.
POSIX.1-2001 specifies that if the disposition of SIGCHLD is set to SIG_IGN or the
SA_NOCLDWAIT flag is set for SIGCHLD (see sigaction(2)), then children that terminate
do not become zombies and a call to wait() or waitpid() will block until all
children have terminated, and then fail with errno set to ECHILD. (The original POSIX
standard left the behavior of setting SIGCHLD to SIG_IGN unspecified. Note that even
though the default disposition of SIGCHLD is "ignore", explicitly setting the
disposition to SIG_IGN results in different treatment of zombie process children.)
Linux 2.6 conforms to this specification. However, Linux 2.4 (and earlier) does
not: if a wait() or waitpid() call is made while SIGCHLD is being ignored, the
call behaves just as though SIGCHLD were not being ignored, that is, the call blocks
until the next child terminates and then returns the process ID and status of that
child.
setsid() 시스템 호출은 하위 프로세스를 상위 프로세스에서 분리하여 독립 프로세스로 만들지 만 닫지 않은 경우 stdin/stdout을 공유합니다. – pelya