Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Getting STDERR from forked child processes?

Reply
Thread Tools

Getting STDERR from forked child processes?

 
 
Zbigniew Fiedorowicz
Guest
Posts: n/a
 
      02-05-2004
How can I catch error messages from external programs forked
from a Perl cgi process? I can of course read from the web
server error log, but I am worried that I might be getting
the wrong error messages from some other web server process
which is running concurrently.

TIA,
Zig Fiedorowicz

 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      02-05-2004
Zbigniew Fiedorowicz <> writes:

> How can I catch error messages from external programs forked
> from a Perl cgi process?


Can you explain how your question differs from the FAQ: "How can I
capture STDERR from an external command?"

Note: the FAQ doesn't mention you can also do fork/reopen STDOUT/exec
as you would in C.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 
Reply With Quote
 
 
 
 
Aaron Sherman
Guest
Posts: n/a
 
      02-05-2004
Zbigniew Fiedorowicz <> wrote in message news:<bvto7c$9k$>...
> How can I catch error messages from external programs forked
> from a Perl cgi process? I can of course read from the web
> server error log, but I am worried that I might be getting
> the wrong error messages from some other web server process
> which is running concurrently.


Do you mean fork()ed or do you mean a truely external program (e.g.
using system, qx{} or fork()/exec)?

Let's use qx{} (aka ``) as a simple example:

method a:

$result_plus_err = qx{/usr/bin/do_stuff 2>&1};

method b:

use IPC::Open3 qw(open3);
use IO::Select;
open3(\*WTRFH, \*RDRFH, \*ERRFH, "/usr/bin/do_stuff");
close WTRFH;
my $r = IO::Select->new(\*RDRFH,\*ERRFH);

and from there you can call the "can_read" method on $r and continue
along your happy way.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
STDOUT and STDERR redirection fails for forked process Peter Perl Misc 1 07-20-2007 06:02 PM
STDOUT and STDERR redirection fails for forked process Peter Perl Misc 1 07-19-2007 09:43 AM
Java waitfor waits for completion of forked child pwu@qantas.com.au Java 2 08-25-2005 08:58 AM
Reading variables from a forked child (Python C/API) Donn Cave Python 2 07-15-2005 09:56 PM
How to kill a forked child process... Moritz Karbach Perl Misc 11 06-20-2005 09:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57