Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-01

TProcess and zombie processes in *nix systems

4 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

In fgGUI applications I often launch other applications. eg: The help viewer etc. In such cases, I simply want to launch the application and then forget about it. I have no need to read any stdout etc.

I've been using TProcess for this task as follows:

  p := TProcess.Create(nil);
  try
    p.Executable := ...
    p.Execute;
  finally
    p.free
  end;

As TProcess is a TComponent descendant, I specify nil as the Owner, thus I manually free it. It was brought to my attention that if the user has a long running application (eg: an RSS feed reader - lunching a web browser via TProcess), after a while they have many Zombie processes in Linux hanging around until the fpGUI application terminates.

Two things:

1. The way I create the TProcess. Why or how does it have a dependency on the fpGUI application?

2. Anybody else experience this zombie processes hanging around in *nix systems? Is there any option in TProcess to prevent that?

ie: I want to launch a new application in a separate OS process and then forget about it.

Regards,
Graeme

Reply by email

Marco van de Voort
to Graeme Geldenhuys

Op 2020-01-21 om 21:40 schreef Graeme Geldenhuys:

ie: I want to launch a new application in a separate OS process and then forget about it.

This is the responsibility of the callee I think, to daemonize and cut the cord so to speak.

Reply by email

Sven Barth
to Marco van de Voort: Op 2020-01-21 om 21:40 schreef Graeme Geldenhuys: This is the responsibility of the…
Marco van de Voort wrote 8 lines
Op 2020-01-21 om 21:40 schreef Graeme Geldenhuys: >   ie: I want to launch a new application in a separate OS process and > then > forget about it. This is the responsibility of the callee I think, to daemonize and cut the cord so to speak.

Indeed, doesn't seem to be that easy:
https://stackoverflow.com/questions/27361227/how-to-prevent-creation-of-zombie-processes-while-using-fork-and-exec-in-lin

Regards,
Sven

Reply by email