in reply to reading from a named pipe

I don't know why it works on one but not the other, but I can see a possible problem if two messages arrive in quick succession

You read only a single line from the pipe on each open, but you're using buffered input, so it's possible if two messages arrive in quick succession that for the <$fifo> PerlIO reads both lines into the buffer, and readline() (aka <>) returns the first of those two lines

You then re-open the pipe each time around the loop and discard the buffered line.

Given what you've shown I don't see why you don't just have a classic while (my $line = <$fifo>) { ... } loop.

Replies are listed 'Best First'.
Re^2: reading from a named pipe
by skendric (Novice) on Jun 10, 2024 at 12:46 UTC

    Dang, I was getting too complicated there, with the alarms and opening and closing the pipe ... simplifying per your suggestion has fixed the issue under Ubuntu, and it still works fine under Rocky

    # Open pipe OPENPIPE: unless (open $fifo, '<', $pipe) { log_it("Cannot open $pipe: $!"); sleep 5; next OPENPIPE; } READPIPE: while (my $line = <$fifo>) { next READPIPE unless defined $line; chomp $line; # Process line next READPIPE unless $clean = strip_junk($line); next READPIPE unless $log = find_log_name($clean); ($text) = ($clean) =~ /^\w+\s+(.*)/; write_line($text); }
    Thank you, --sk