diff options
author | Robert Rothenberg <rrwo@cpan.org> | 2020-03-29 13:02:56 +0100 |
---|---|---|
committer | Robert Rothenberg <rrwo@cpan.org> | 2020-03-29 13:02:56 +0100 |
commit | 15d470de6f0b00043dc070a76627e817e3aad1f3 (patch) | |
tree | a7b122ec601b0201f2875ee5468a6a8f0fef0c9f | |
parent | 8fc59f14702d9f802471ca0926dab0259e95e362 (diff) |
return undef if path to uptime cannot be found
-rw-r--r-- | Changes | 3 | ||||
-rw-r--r-- | lib/Sys/CpuLoad.pm | 3 |
2 files changed, 5 insertions, 1 deletions
@@ -4,6 +4,9 @@ Revision history for Perl extension {{$dist->name}}: [Enhancements] - Support getloadavg for DragonFly BSD. + [Bug Fixes] + - uptime immediately returns undef if path to `uptime` cannot be found. + [Tests] - Fixed test when skipping getloadavg test. diff --git a/lib/Sys/CpuLoad.pm b/lib/Sys/CpuLoad.pm index 6bc878e..8135150 100644 --- a/lib/Sys/CpuLoad.pm +++ b/lib/Sys/CpuLoad.pm @@ -103,7 +103,8 @@ sub uptime { local %ENV = %ENV; $ENV{'LC_NUMERIC'} = 'POSIX'; # ensure that decimal separator is a dot - $uptime ||= which("uptime"); + $uptime ||= which("uptime") or + return undef; ## no critic (ProhibitExplicitReturnUndef) my $fh = IO::File->new("${uptime}|"); if ( defined $fh ) { |