From c63d371652d838c5c8a4f822114dbb9a8e21bac2 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 68011078a5..238a6724a3 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 f45546012bccc699f3d1e6a8198209d48df0c1aa 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 238a6724a3..82fb775c64 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 f9c4c1c746be6dabc5299805e5718ca9a1481bda 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 82fb775c64..96f6a840bb 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 {