Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: fork and stdout/stderr

by MarkM (Curate)
on Feb 25, 2003 at 05:26 UTC ( [id://238360]=note: print w/replies, xml ) Need Help??


in reply to fork and stdout/stderr

Various ways of accomplishing the effect that you are looking for:

  1. Use ">/tmp/command.out 2>/tmp/command.err" in the shell command string. Read the files after the command completes, and remove the files.
  2. Use IPC::Open3() and select() to monitor all pipes, reading data from pipes that have data ready.
  3. Spawn a thread off to read data from each sub process pipe. The thread would update a shared variable as data arrived on the pipe. The thread would exit when the pipe was closed.

In order to decide which method would work best, many factors need to be analyzed, including the acceptable level of complexity of the final product, the efficiency of the product, the purpose for capturing stdout/stderr, and the host environment (UNIX vs WIN32).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-19 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found