From 1385c83b51a5a90e5b4434cde7caadd3ed3d79af Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 29 Mar 2016 01:19:01 -0400 Subject: [PATCH] Add check logic before using perl-Error library perl-Error lib is not included in the system package of sles 11.4 by default. Load Error lib with eval and require statement to avoid of dependency error. Close issue: #857 --- perl-xCAT/xCAT/Utils.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 8dc8dc046..c59db5e57 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -16,7 +16,6 @@ if ($^O =~ /^aix/i) { use lib "$::XCATROOT/lib/perl"; # do not put a use or require for xCAT::Table here. Add to each new routine # needing it to avoid reprocessing of user tables ( ExtTab.pm) for each command call -use Error; use POSIX qw(ceil); use File::Path; use Socket; @@ -4644,9 +4643,21 @@ sub lookupNetboot{ sub is_process_exists{ my $pid = shift; return 1 if $pid == 0; + # NOTE: Add eval and require to process dependency missing of perl-Error + # package before sles 12 system. + my $miss = undef; + eval { + require Error; + }; + if ($@) { + $miss = 1; + } my $ret = kill(0, $pid); - return 0 if ($!{ESRCH}); - return 1 if ($!{EPERM}); + + if (!$miss) { + return 0 if ($!{ESRCH}); + return 1 if ($!{EPERM}); + } if ($ret != 0 ) { return 1;