in reply to Re: redirecting STDOUT (of a system call) to a var
in thread redirecting STDOUT (of a system call) to a var

Doesn't calling waitpid() (as documented) after using open2() or open3() also give you the exit status?

        - tye (but my friends call me "Tye")
  • Comment on (tye)Re: redirecting STDOUT (of a system call) to a var

Replies are listed 'Best First'.
(particle)Re: (tye)Re: redirecting STDOUT (of a system call) to a var
by particle (Vicar) on Jun 28, 2001 at 20:24 UTC

    BRILLIANT!

    now i call waitpid(-1,0), and the value of $? is the return value from the open! this will make my programming life MUCH easier!

    thank you tye.

    in case this helps anyone else, the code that's changed is:

    eval { $pid = open3("<&STDIN", \*OUTPUT, \*OUTERR, 'perl return.pl') ; $val = waitpid(-1,0); # <--- added this line }; ... print "---pid$n"; print $pid . $n; # <--- prints pid print "---val$n"; print $val . $n; # <--- prints pid print "---\$?$n"; print $? >>8, $n; # <--- prints exit val
    i am amazed. and VERY happy.

    ~Particle