On Mon, Aug 19, 2002 at 01:43:52AM -0300, Cristiano Lincoln Mattos wrote:
>
> This works OK in linux, but under Cygwin, the the connection
> filehandle/socket and the filehandles that are used to execute the
> external program are somehow linked... the connection is only
> terminated after the program ends. In the test case below, the
> program to be executed is just "/bin/ls; sleep 10; /bin/ls".
> Under cygwin, the socket stays alive until all the execution is
> finished. Under linux, everything works OK, with the connection
> being close, and the execution happenning independently.
[...]
gotConnectionInput() looks ok. It catches "doit" and initiates the
action. You indicated that the action occurs, so the code here is
running. Do your clients receive the "Got it, executing... bye"
message before or after the program finishes?
> sub gotConnectionInput {
> my ($heap, $kernel) = @_[HEAP, KERNEL];
> my ($input) = $_[ARG0];
> print "[CONN] => $input\n";
>
> if ($input =~ /doit/) {
> $heap->{connection}->put("Got it, executing... bye\n");
> $heap->{shutdownOK} = 1;
> $kernel->yield("runJob");
> }
> }
[...]
I think the local filehandles here will cause problems if runJob() is
re-entered. I usually use Symbol's gensym() method to create lexical
filehandles instead. This probably has nothing to do with the problem
at hand.
Is it possible that open3() isn't returning until $path has finished?
> sub runJob {
> my ($heap, $kernel) = @_[HEAP, KERNEL];
>
> print "Running job...\n";
> local(*WRT);
> local(*RD);
> local(*ERR);
>
> my $path = "/bin/ls -laF /; sleep 5; /bin/ls";
> my $pid = open3(*WRT, *RD, *ERR, $path);
>
> my $wrt = *WRT;
> my $rd = *RD;
> my $err = *ERR;
>
> my $w;
> my $w2;
> $w = POE::Wheel::ReadWrite->new(
> InputHandle => $rd,
> OutputHandle => $wrt,
> Driver => POE::Driver::SysRW->new(),
> Filter => POE::Filter::Stream->new(),
> ErrorEvent => "Joberror",
> FlushedEvent => "JobstdinFlushed",
> InputEvent => "JobstdoutInput",
> );
> $w2 = POE::Wheel::ReadWrite->new(
> Handle => $err,
> Driver => POE::Driver::SysRW->new(),
> Filter => POE::Filter::Stream->new(),
> ErrorEvent => "Joberror",
> InputEvent => "JobstderrInput",
> );
>
> $heap->{stdin}{Wheel} = $w;
> $heap->{stderr}{Wheel} = $w2;
>
> }
-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net