Running processes show <defunct> after closing launche

Linux specific forum
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Running processes show <defunct> after closing launche

Post by Beach »

I have an app that is calling other external apps with "RunProgram". When I close the external launched app, it still show up in the process list with a "<defunct>" beside it. I read that it has something to do with waiting for the parent app (that launched it) to shut it down.

Are there any problems associated with this? Just curious.
-Beach
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

I remember having this same problem in the beginning with the IDE/debugger on linux.
I don't remember how i solved it though.

Basically it means that the child process did not terminate correctly and is
somehow messed up. By using either a wait function (like waitpid_()) or
terminating the parent it should go away. (My guess is that when you do
this, the system knows that the parent is no longer connected to the child
and does a proper cleanup of the process)

This does mean that something went wrong, and iirc, by changing the way i terminated
the child process i was able to fix it.

As far as wether this is a problem: Well, it creates dead processes that consume
system resources. Its not dangerous or anything, but its just not a good way to do it either.

How exactly do you terminate the child process? (with PB's End, with exit_(), wil a kill ?)
And what does the child do? (does it use gtk, does it use any sort of pipes?)

Maybe with some hints i can remember what my problem was exactly with this and tell you its solution ;)
quidquid Latine dictum sit altum videtur
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

freak wrote:I remember having this same problem in the beginning with the IDE/debugger on linux.
I don't remember how i solved it though.

Basically it means that the child process did not terminate correctly and is
somehow messed up. By using either a wait function (like waitpid_()) or
terminating the parent it should go away. (My guess is that when you do
this, the system knows that the parent is no longer connected to the child
and does a proper cleanup of the process)

This does mean that something went wrong, and iirc, by changing the way i terminated
the child process i was able to fix it.

As far as wether this is a problem: Well, it creates dead processes that consume
system resources. Its not dangerous or anything, but its just not a good way to do it either.

How exactly do you terminate the child process? (with PB's End, with exit_(), wil a kill ?)
And what does the child do? (does it use gtk, does it use any sort of pipes?)

Maybe with some hints i can remember what my problem was exactly with this and tell you its solution ;)
One of the external apps is "xterm". I use something like RunProgram("xterm","-e ping localhost") which will open a x terminal and executes the command "ping localhost". When you do a control-c in the terminal window, xterm will close automatically. Looks normal until you check the processes. No big deal, they all go away after my pb app closes.

Thanks for your reply.
-Beach
Post Reply