R
rihad
This function is from a daemon (long-lived process):
sub foo($) {
my ($command) = shift;
BEGIN {
open(FOO, ">/var/tmp/foo") or return;
my $old_fh = select(FOO);
$| = 1;
select($old_fh);
}
print FOO "$command\n";
END {
close(FOO);
}
}
/var/tmp/foo is a FIFO (mkfifo). It also has a reader daemon (not
shown).
Now when foo('blah-blah-blah') is called, nothing gets written to the
FIFO. Even if I call it several times in succession. I need to stop
the Perl daemon to see them finally output. If I get rid of the BEGIN/
END surroundings, everything works, but opening and closing the fifo
every time is a performance hit for me. Maybe I'm not using autoflush
and select in BEGIN properly? Please help, as I'm not experienced with
Perl.
Perl v5.8.8
FreeBSD 7.0
sub foo($) {
my ($command) = shift;
BEGIN {
open(FOO, ">/var/tmp/foo") or return;
my $old_fh = select(FOO);
$| = 1;
select($old_fh);
}
print FOO "$command\n";
END {
close(FOO);
}
}
/var/tmp/foo is a FIFO (mkfifo). It also has a reader daemon (not
shown).
Now when foo('blah-blah-blah') is called, nothing gets written to the
FIFO. Even if I call it several times in succession. I need to stop
the Perl daemon to see them finally output. If I get rid of the BEGIN/
END surroundings, everything works, but opening and closing the fifo
every time is a performance hit for me. Maybe I'm not using autoflush
and select in BEGIN properly? Please help, as I'm not experienced with
Perl.
Perl v5.8.8
FreeBSD 7.0