Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: "Exception" handling and more...

by MZSanford (Curate)
on Nov 26, 2001 at 14:45 UTC ( [id://127516] : note . print w/replies, xml ) Need Help??

in reply to "Exception" handling and more...

If you don't need to know which parts are from stderr, and which are from stdout, i would suggest appending 2>&1 to your command. This will cause the unix shell to rediect them both so you can read them.

On the other hand, if they have to be seperate, i would suggest :
  1. using pipe() twice
  2. fork()'ing off a child.
  3. Using open() in the child to reset STDOUT and STDERR to the writing ends of the pipes.
  4. using exec() in the child to start the command
  5. let the parent (from the fork()) read the other ends of the pipes, and process them seperatly.

... just a thought.
i had a memory leak once, and it ruined my favorite shirt.