Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion t/op/magic.t
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,21 @@ EOP
open my $rfh, '<', "/proc/$$/cmdline"
or skip "failed to read '/proc/$$/cmdline': $!", $skip;
my $got = do { local $/; <$rfh> };
$got=~s/\0\z//;

# Some kernels leave a trailing NUL on. Some add a bunch of spaces
# after that NUL. We want neither.
#
# A selection of kernels/distros tested:
#
# 4.18.0-348.20.1.el8_5.x86_64 (AlmaLinux 8.5): NUL then spaces
# 3.10.0-1160.62.1.el7.x86_64 (CentOS 7.9.2009): no NUL nor spaces
# 2.6.32-954.3.5.lve1.4.87.el6.x86_64 (CloudLinux 6.10): ^^ ditto
#
# 5.13.0-1025-raspi (Ubuntu 21.10): NUL only
# 5.10.103-v7+ (RaspiOS 10): NUL only
#
$got=~s/\0\s*\z//;

return $got;
};

Expand Down