Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: When starting a process, at what point does "open()" return?

by jasonk (Parson)
on Aug 18, 2003 at 02:09 UTC ( #284469=note: print w/replies, xml ) Need Help??


in reply to When starting a process, at what point does "open()" return?

The open call will return when the process exits, if the process hangs and does not exit, then the open will not return unless you arrange for it to be interrupted early (such as by setting an alarm()).

Update: Doh! Of course open doesn't wait for the process to exit, how could you read from the pipe if it did? Apparently I need more sleep...


We're not surrounded, we're in a target-rich environment!
  • Comment on Re: When starting a process, at what point does "open()" return?

Replies are listed 'Best First'.
Re: Re: When starting a process, at what point does "open()" return?
by esh (Pilgrim) on Aug 18, 2003 at 02:25 UTC

    The open call will return when the process exits
    This is not true on operating systems I'm familiar with and I doubt it's true on Windows, either. The open call returns when the process starts not when it exits. You can then have the child process talking with the parent process while both are running at the same time.

    Here's proof:

    perl -e 'open F, "sleep 60 |" or die "$!\n"; print "done\n"'

    I know that "sleep 60" takes about 60 seconds to run, but my top perl program prints "done" right away and exits. It does not wait for the "sleep 60" to exit.

    The related system call does wait for the child return when the child process exits.

    -- Eric Hammond

Re: Re: When starting a process, at what point does "open()" return?
by Anonymous Monk on Aug 18, 2003 at 02:22 UTC
    That's not how it works. If it worked that way, you could never read from a subprocess or write to it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (1)
As of 2021-06-19 10:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (92 votes). Check out past polls.

    Notices?