From 6aab6faf026e8b24960e25c5db7bb9e176d24e52 Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 4 Dec 2012 13:25:52 +0000 Subject: [PATCH] make copycds to abort correctly git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14541 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/sles.pm | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index aebe331f9..0d32237ea 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1193,6 +1193,8 @@ sub copycd } } + + closedir($dirh); unless ($distname and $discnumber) { @@ -1268,15 +1270,24 @@ sub copycd {data => "Copying media to $ospkgpath"}); my $rc; - $SIG{INT} = $SIG{TERM} = sub { + + $SIG{INT} = $SIG{TERM} = sub { foreach(@cpiopid){ - kill 2, $_; - } - if ($mntpath) { + kill 15, $_; + use POSIX ":sys_wait_h"; + my $kid=0; + do { + $kid = waitpid($_, WNOHANG); + } while $kid != $_; + } + if ($mntpath) { chdir("/"); system("umount $mntpath"); - } + system("rm -rf $mntpath"); + } + exit; }; + my $kid; chdir $mntpath; my $numFiles = `find . -print | wc -l`; @@ -1288,6 +1299,7 @@ sub copycd if ($child) { push @cpiopid,$child; my @finddata = `find .`; + chdir("/"); for (@finddata) { print $kid $_; } @@ -1297,6 +1309,7 @@ sub copycd my $c = "nice -n 20 cpio -vdump $ospkgpath"; my $k2 = open(PIPE, "$c 2>&1 |") || $callback->({error => "Media copy operation fork failure"}); + chdir("/"); push @cpiopid, $k2; my $copied = 0; my ($percent, $fout);