weird behavior with open and pipe
- From: Moritz Karbach <moritz.karbach@xxxxxxx>
- Date: Thu, 30 Jun 2005 16:03:44 +0200
Hi,
I'm still tuning the run()-function of my Command class (see some older
postings of mine, if you like).
I'm using
open($fh_child,"-|");
to fork and to open a pipe to the child, which then exec's a system command.
The parent uses
my @output = <$fh_child>;
close($fh_child);
to receive the output. Here is the problem:
If the childs executes a certain system command and the system command gets
killed externally (by a watchdog), sometimes the parent doesn't receive any
output! Yes, I'm sure, that the system command has written something to std
out before it got killed.
The weird thing is, that if I execute something like
<test.sh>
#!/bin/bash
echo "this is a test"
sleep 10
</test.sh>
and if I kill the process after say 5 seconds, the parent indeed receives
the line "this is a test"!
Obviously it must be some difference in the binaries/system commands. Any
idea, what could be the reason for this difference? Is there a possible
workaround?
I already tried
while ( my $line = <$fh_child> )
{
push ( @{$this->{output}}, $line );
#print "X " . $line;
}
without success...
Cheers,
- Moritz
.
- Follow-Ups:
- Re: weird behavior with open and pipe
- From: Anno Siegel
- Re: weird behavior with open and pipe
- Prev by Date: Re: Copy local Groups -- Get SID
- Next by Date: Re: SOAP::Lite proxied
- Previous by thread: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS,NT,...]?
- Next by thread: Re: weird behavior with open and pipe
- Index(es):
Relevant Pages
|