2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 11:42:05 +00:00

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
This commit is contained in:
chenglch 2016-03-29 01:19:01 -04:00
parent f874f3a22b
commit 1385c83b51

View File

@ -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;