Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Variable triggers global destruction hang

by ikegami (Patriarch)
on Sep 12, 2009 at 06:44 UTC ( [id://794896]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Variable triggers global destruction hang
in thread Variable triggers global destruction hang

Neither of those hang for me. (5.8.8 on linux)

Update: I just figured out why it hangs in 5.10+.

Closing the Perl handle will cause perl to close the system handle and wait for cat to end.

Without duping: Since the pipe is closed on Perl's side, it gets closed on cat's side and cat exits. perl's wait is short.

With duping and STDOUT gets closed after FH: Since the pipe is still open on Perl's side because of the dup, it doesn't gets closed on cat's side and cat doesn't exit. perl's wait is "infinite".

With duping and STDOUT gets closed before FH: It's like there was no duping.

(The order in which stuff gets freed during global destruction is undefined and/or unpredictable.)

Replies are listed 'Best First'.
Re^4: Variable triggers global destruction hang
by ig (Vicar) on Sep 12, 2009 at 07:03 UTC

    But the OP has duplicated the file handle in both cases.

    I have tried with 5.8.8 (redhat build) and 5.10.0 (default build) on Linux. Neither waits on the sub-process - neither hangs. But the OP says 5.10 hangs with either form. If it is hanging waiting for the sub-process, then something very different is happening.

    So, question for the OP: who's build and on what platform are you seeing this?

      But the OP has duplicated the file handle in both cases.

      huh?

      open FH , "| cat " or die ; open STDOUT, ">&FH"or die ; <-- dup
      open FH , "| cat " or die ; <-- no dup

      But the OP says 5.10 hangs with either form

      huh? He asked "what is the reason that [the one with duping] hangs while [the one without duping] doesn't?" Clearly, both don't hang for him.

        I'm confused. The two cases I see in the original post are:

        open FH , "| cat " ; open STDOUT, ">&FH";

        and

        my $foo = qr(a); open FH , "| cat " ; open STDOUT, ">&FH";

        FH is duplicated to STDOUT in both cases.

        And, saintmike said:

        Just verified: With an old perl-5.8 I get the different behavior with/without the variable, with perl-5.10 it hangs regardless.

        I took this to mean that with 5.10 it hangs waiting for the sub-process to terminate.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://794896]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-26 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found