I guess that journalctlworks like tail -f. If this is correct, the downtime openshould complete the task:
use Fcntl;
my $pid = open my $fh, '|-', 'journalctl --follow'
or die "Error $! starting journalctl";
while (kill 0, $pid) {
while (<$fh>) {
print $_;
}
sleep 1;
seek($fh,0,SEEK_CUR);
}
open : http://perldoc.perl.org/functions/open.html
seek reset EOF: http://perldoc.perl.org/functions/seek.html reset <$fh> EOF, script .
kill 0,$pid , , open, .
sleep 1 usleep Time::HiRes select undef,undef,undef,$fractional_seconds;, .
AnyEvent AnyEvent::Handle.
Update:
use POSIX ":sys_wait_h"; waitpid $pid, WNOHANG) ( ) journalctl:
while (kill(0, $pid) and waitpid($pid, WNOHANG) != $pid) {
, , , $pid ($$), journalctl .