Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: How to set pipe first and then use the forkmanager?

by mlin (Novice)
on Sep 22, 2016 at 10:51 UTC ( [id://1172362]=note: print w/replies, xml ) Need Help??


in reply to Re: How to set pipe first and then use the forkmanager?
in thread How to set pipe first and then use the forkmanager?

Because establish the pipe to the program may be a little bit time-consuming. So I would like to move the open pipe outside the foreach() in the serial type. Similarly I consider may be I should establish pipe first and then use fork.
  • Comment on Re^2: How to set pipe first and then use the forkmanager?

Replies are listed 'Best First'.
Re^3: How to set pipe first and then use the forkmanager?
by Laurent_R (Canon) on Sep 22, 2016 at 14:57 UTC
    Presumably, you're forking because your input data files are very large. The time taken to open a pipe is then negligible compared to the time needed for processing your data.

    Don't forget that premature optimization is the source of almost all evil.

      Thanks! I'll use this form at the moment, maybe I solve the problem when I know more about the fork. I have a new question: ----- complement: while the program A runs, it usually prints some information or warnings to the screen? Will it be a trouble for the forked processes? or I must throw the output of A, like:
      foreach (@data_files) { open $h, "| program_A 2>& /dev/null" or die ...; print $h ...; print $h ...; ... } close($h);
      Can I hold those information? Thanks!
        Hmm, not entirely sure, but I don't think that the forked process will care about that.

        On the other hand, you might want to redirect to a log file (not /dev/null), if only to help getting a diagnostic if your process has errors and fails.

Log In?
Username:
Password:

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

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

    No recent polls found