PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: James Zukowski on November 30, 2018, 01:51:15 PM

Title: <defunct> Linux Processes
Post by: James Zukowski on November 30, 2018, 01:51:15 PM
We seem to have a lot of zombie processes on our Linux server, e.g.:
     user_id  26008 21801  0 13:37 ?        00:00:00 [date] <defunct>
Most of them seem to be a result of:
Code: [Select]
Temp$=""; open (hfn)"<date"; read (lfo,err=*proceed)Temp$; close (lfo)When the user logs out, then yes, the zombie disappears, but until then, it just hangs around, getting its time updated whenever that date call is processed. According to some online comments, these hang around "because their parent has not destroyed them properly." Also, "On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the parent process to read its child's exit status."
Is there anything we need to do to ensure these will disappear promptly, or do we simply have to wait for the user to log out?
Thanks, all!
Title: Re: <defunct> Linux Processes
Post by: Mike King on December 03, 2018, 01:16:41 PM
When dealing with pipes you may need to set the 'WP' system parameter.

The issue is that with 'WP' set to zero we don't wait for the pipe process to complete when you issue a close.  This means that the termination status is still to be processed which is why the process hangs around in memory.

This approach allows you to create a pipe process, send it some data then close the pipe and monitor the process using the SYS function.

If you set the 'WP' parameter to 1 the system will wait for the process to ends avoiding these zombies..

NOTE: A subsequent pipe request will cause the system to clear the preceding request so no task will ever have more than one zombie process.  These will also be cleared when the PxPlus process ends.
Title: Re: <defunct> Linux Processes
Post by: James Zukowski on December 03, 2018, 01:38:52 PM
Unfortunately, we also have some piped processes that take quite a while (UnForm). Rather than have a user wait for that to complete, we decided to have the program return immediately. I guess that means we'll have to live with the zombies lurking...
Title: Re: <defunct> Linux Processes
Post by: Mike King on December 03, 2018, 02:27:30 PM
The 'WP' only impacts the close of a pipe -- not invokes or any other OS spawn.

You can also set/reset this parameter as required so you could just wrap your open/close of <date with setting/resetting the 'WP' parameter.