From 0942945004cb5fcf1eca7a52a91a09b3b9cfe02c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 13 Aug 2025 21:42:47 +0000 Subject: [PATCH] extindex: improve error checking with try_cat PublicInbox::IO::try_cat will detect read(2) errors properly instead of relying on the readline perlop for error checking. --- lib/PublicInbox/ExtSearchIdx.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm index 923de7873..931075908 100644 --- a/lib/PublicInbox/ExtSearchIdx.pm +++ b/lib/PublicInbox/ExtSearchIdx.pm @@ -40,6 +40,7 @@ use PublicInbox::DS qw(now add_timer); use DBI qw(:sql_types); # SQL_BLOB use PublicInbox::Admin qw(fmt_localtime); use PublicInbox::Config qw(rel2abs_collapsed); +use PublicInbox::IO qw(try_cat); sub new { my (undef, $dir, $opt) = @_; @@ -698,8 +699,7 @@ sub host_ident () { # these while this process is running and we always want to be # able to release locks taken by this process. state $retval = hostname . '-' . do { - my $m; # machine-id(5) is systemd - if (open(my $fh, '<', '/etc/machine-id')) { $m = <$fh> } + my $m = try_cat '/etc/machine-id'; # machine-id(5) is systemd # (g)hostid(1) is in GNU coreutils, kern.hostid is most BSDs chomp($m ||= `{ sysctl -n kern.hostid || hostid || ghostid; } 2>/dev/null` -- 2.47.3