suvitha
suvitha

Reputation: 113

What are the reasons for child process not exiting properly?

The child process which is forked, is working and not exiting(killed) properly. what are the possible instances for this to happen?

Upvotes: 2

Views: 2663

Answers (2)

Chris DuPuis
Chris DuPuis

Reputation: 201

Is the parent process wait()ing for the exit status of the child? Have you tried the WIFSIGNALED() and WTERMSIG() macros on the value returned from wait() to see if the child was terminated by a signal, and, if so, which one?

Upvotes: 0

caf
caf

Reputation: 239011

It is possible that the child is a Zombie.

After a child process exits, it goes into the Z (Zombie) state. This state exists to hold the exit status of the child until the child's parent process can retrieve it, and to prevent the child's PID from being reused until the parent has been notified of the child's exit.

The parent process is notified that the child process has exited through calling one of the wait() / waitpid() family of system calls. Usually, this is done in response to a SIGCHLD signal. Once the parent has done this, the child PID will be released and the Zombie process will disappear.

(Alternatively, if the parent process exits, all its outstanding child processes will be reparented to init, which will call waitpid() on them as they exit).

Upvotes: 1

Related Questions