summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Rothenberg <rrwo@cpan.org>2020-03-29 13:02:56 +0100
committerRobert Rothenberg <rrwo@cpan.org>2020-03-29 13:02:56 +0100
commit15d470de6f0b00043dc070a76627e817e3aad1f3 (patch)
treea7b122ec601b0201f2875ee5468a6a8f0fef0c9f
parent8fc59f14702d9f802471ca0926dab0259e95e362 (diff)
return undef if path to uptime cannot be found
-rw-r--r--Changes3
-rw-r--r--lib/Sys/CpuLoad.pm3
2 files changed, 5 insertions, 1 deletions
diff --git a/Changes b/Changes
index 854328f..0a985cb 100644
--- a/Changes
+++ b/Changes
@@ -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 ) {