From dd394f6f6e1c6d2030d639d7ebcf4d62f1d38e4f Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 12 Mar 2019 15:30:25 +0800 Subject: [PATCH 1/3] Handle the exit code of child process properly --- xCAT-server/lib/xcat/plugins/anaconda.pm | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 68011078a..238a6724a 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2250,7 +2250,7 @@ sub copycd print $KID $_ . "\n"; } close($KID); - $rc = $?; + $rc = $? >> 8; } else { @@ -2267,16 +2267,8 @@ sub copycd $callback->({ sinfo => "$fout" }); ++$copied; } - if ($copied == $numFiles) - { - #media copy success - exit(0); - } - else - { - #media copy failed - exit(1); - } + close(PIPE); + exit($? >> 8); } #my $rc = system("cd $path; find . | nice -n 20 cpio -dump $installroot/$distname/$arch"); From 0278e8962cd26d893ebb9a85460ece481fef2713 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 12 Mar 2019 15:41:43 +0800 Subject: [PATCH 2/3] Handle the output of cpio properly --- xCAT-server/lib/xcat/plugins/anaconda.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 238a6724a..82fb775c6 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2261,7 +2261,11 @@ sub copycd my $copied = 0; my ($percent, $fout); while () { - next if /^cpio:/; + if (/^cpio:/) { + chomp; + $callback->({ data => $_ }); + next; + } $percent = $copied / $numFiles; $fout = sprintf "%0.2f%%", $percent * 100; $callback->({ sinfo => "$fout" }); From 3089a256e59c495160980bc4da70bbc95e9318a0 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 12 Mar 2019 16:06:08 +0800 Subject: [PATCH 3/3] Handle the exit code properly --- xCAT-server/lib/xcat/plugins/anaconda.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 82fb775c6..96f6a840b 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2293,7 +2293,7 @@ sub copycd if ($rc != 0) { - $callback->({ error => "Media copy operation failed, status $rc" }); + $callback->({ error => "Media copy operation failed, status $rc", errorcode => [1] }); } else {