M
Moritz Karbach
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
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