Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Catalyst and IPC::Open2

by holli (Abbot)
on Aug 02, 2007 at 06:22 UTC ( [id://630220]=perlquestion: print w/replies, xml ) Need Help??

holli has asked for the wisdom of the Perl Monks concerning the following question:

Brethren, I have the following Catalyst-Controller
sub test1 : Local { my ( $self, $c ) = @_; my $konf = ECS::Inkasso::Konfig->new(); my $bin = $konf->{location}->{bin}; my $pro = $konf->{location}->{progress}; print STDERR ">>P start\n"; my($chld_out, $chld_in); open2($chld_out, $chld_in, "perl", "$bin/x2.pl", "$pro/foo.txt"); print STDERR ">>P end\n"; $c->res->redirect( $c->req->base."/forderung/importieren/progress_ +bar" ); }
As you see the code uses IPC::Open2 to spawn off (should survive the creating process) x2.pl:
#x2.pl for ( 0.. 10 ) { open $out, ">$ARGV[0]"; print $out "$_\n"; close $out; sleep(1); }
The problem: From the Catalyst output I see the action gets called:
>>P start >>P end [info] *** Request 1 (0.025/s) [4040] [Thu Aug 2 08:13:30 2007] *** [debug] "GET" request for "forderung/importieren/test1" from "127.0.0. +1" [debug] Path is "forderung/importieren/test1" [debug] Redirecting to "http://localhost:3000//forderung/importieren/p +rogress_bar" [info] Request took 0.208057s (4.806/s) .----------------------------------------------------------------+---- +-------. | Action | Tim +e | +----------------------------------------------------------------+---- +-------+ | /begin | 0.0 +72754s | | /auto | 0.0 +00065s | | /forderung/importieren/test1 | 0.0 +00891s | '----------------------------------------------------------------+---- +-------'
However, no response gets ever sent to the browser. If I comment out the open2() line, everything works as expected. What's happening here? Does open2() something fancy with STDOUT?


holli, /regexed monk/

Replies are listed 'Best First'.
Re: Catalyst and IPC::Open2
by moritz (Cardinal) on Aug 02, 2007 at 06:48 UTC
    To test if the problem is STDOUT fiddling, you can localize *STDOUT in your scope (and put only open2 in that scope).
Re: Catalyst and IPC::Open2
by holli (Abbot) on Aug 24, 2007 at 09:14 UTC
    Followup and solution here.


    holli, /regexed monk/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://630220]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-08-10 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When will the AI bubble burst?






    Results (22 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.