Re: subprocesses lifecycle



Eric Pozharski <whynot@xxxxxxxxxxxxxx> wrote:

And what surprises me most is that, as Hans Mulder discovered, lexical
filehandles are waited, globals are not. Wouldn't someone willing to dig
through source and explain why that's that way?

I am guessing it is because lexicals are destroyed when they go out of
scope, while globals are only destroyed during "global destruction", during
which time the automatic waiting behavior may not be working.

If one uses circular refs to prevent a lexical filehandle from going out of
scope until global destruction, they don't wait. For example,
the below exits immediately:

perl -le ' my @y; open $y[0], "sleep 5 |" or die; push @y,\@y'

Sometimes it waits anyway. Global destruction is hard to predict.
This waits:

perl -le ' my @y; open $y[0], "sleep 5 |" or die; push @y,\@y; $z=bless {}'


Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
.



Relevant Pages

  • Re: # and lambda
    ... | WHOOSH ... (funcall whoosh))) ... And if CL had non-special globals, we could add one more still: ... lexicals" would be cheating, since it needs to point to some *other* ...
    (comp.lang.lisp)
  • Re: Using map to assign var values from hash
    ... Symbolic references point to globals, not lexicals, but declaring $a, ... form the starting point of all that is necessary in government: ...
    (comp.lang.perl.misc)
  • Re: How to release memory ?
    ... So according to what Is said, lexicals cannot release their memory because "It is reserved in case the variables come back into scope" while globals can. ... my perl is compiled with system malloc: ...
    (comp.lang.perl.misc)