std.process: spawnProcess
Russel Winder
russel at winder.org.uk
Sat Sep 8 10:56:59 UTC 2018
On Sat, 2018-09-08 at 10:24 +0000, FreeSlave via Digitalmars-d-learn wrote:
> On Friday, 7 September 2018 at 14:36:42 UTC, Russel Winder wrote:
> > From what I can see, processes created with std.process:
> > spawnProcess are not terminated when the creating process
> > terminates, i.e. it seems Config.detached is the default for
> > these process.
>
> No, detached is not default. By default you should call wait on
> processes to free OS resources. Process may stay as zombie
> otherwise and it can be visible in process manager.
Annoying but yes, it looks like having a global registry of processes has to
be created so they can be killed on main termination. :-(
Though I am going to tinker with Basile B's suggestion of using a managing
object with a destructor to see if that can avoid the global registry.
> > Is there a way of all spawned processes being terminated on
> > main termination?
>
> You probably need to register all child processes. Or spawn them
> as detached so you won't need to worry about freeing them.
Detached is not a good idea, the spawned processes should not outlive the
spawning process.
--
Russel.
===========================================
Dr Russel Winder t: +44 20 7585 2200
41 Buckmaster Road m: +44 7770 465 077
London SW11 1EN, UK w: www.russel.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180908/aea7e9f4/attachment.sig>
More information about the Digitalmars-d-learn
mailing list