Is there any way to restart or recover the process if it goes into defunct state?

1.5k views Asked by At

My django+ngnix application server goes down frequently without proper information. So I checked the logs and can see the process goes into defunct state.

3072 ? 00:18:41 uwsgi
4045 ? 01:00:56 uwsgi Defunct

So restarted the process and worked for now.

Anyone know the reason why the server goes down frequently, uwsgi dies? also is there any way to restart or recover the process if it goes into defunct state?

Thanks in Advance.

2

There are 2 answers

5
John Hascall On

A <Defunct> process is dead. It's just hanging around until its parent process retrieves its exit status. There is nothing that can be done to it.

If you kill its parent, then it is re-parented to the init process (process #1) which will retrieve its status (and discard it), which will cause the defunct process to vanish from ps

0
AudioBubble On

A defunct process is a zombie process and such process has exited from system but it's exit code is not received by its parent process because its parent has exited before it hence its entry is present in ps table.

But such processes does not consume your resources.

You can avoid this by using a wait condition in its parent process.

So that parent will wait for the child to exit successfully and then parent will exit from system.