-Have anaconda plugin abort copycds cleanly when ctrl-c pressed
-Have xcatd be a bit more thorough about killing processes on certain events git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1136 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
dae998e15b
commit
e0840e7367
@ -2,6 +2,8 @@
|
||||
package xCAT_plugin::anaconda;
|
||||
use Storable qw(dclone);
|
||||
use Sys::Syslog;
|
||||
use Thread qw(yield);
|
||||
use POSIX qw(WNOHANG nice);
|
||||
use xCAT::Table;
|
||||
use xCAT::Utils;
|
||||
use xCAT::MsgUtils;
|
||||
@ -14,6 +16,7 @@ Getopt::Long::Configure("bundling");
|
||||
Getopt::Long::Configure("pass_through");
|
||||
use File::Path;
|
||||
use File::Copy;
|
||||
my $cpiopid;
|
||||
|
||||
my %distnames = (
|
||||
"1176234647.982657" => "centos5",
|
||||
@ -424,7 +427,29 @@ sub copycd {
|
||||
my $omask=umask 0022;
|
||||
mkpath("$installroot/$distname/$arch");
|
||||
umask $omask;
|
||||
my $rc = system("cd $path; find . | nice -n 20 cpio -dump $installroot/$distname/$arch");
|
||||
my $rc;
|
||||
my $reaped=0;
|
||||
$SIG{INT} = $SIG{TERM} = sub { if ($cpiopid) { kill 2, $cpiopid; exit 0; } };
|
||||
my $KID;
|
||||
chdir $path;
|
||||
my $child = open($KID,"|-");
|
||||
unless (defined $child) {
|
||||
$callback->({error=>"Media copy operation fork failure"});
|
||||
return;
|
||||
}
|
||||
if ($child) {
|
||||
$cpiopid = $child;
|
||||
my @finddata = `find .`;
|
||||
for (@finddata) {
|
||||
print $KID $_;
|
||||
}
|
||||
close($KID);
|
||||
$rc = $?;
|
||||
} else {
|
||||
nice 10;
|
||||
exec "nice -n 20 cpio -dump $installroot/$distname/$arch";
|
||||
}
|
||||
#my $rc = system("cd $path; find . | nice -n 20 cpio -dump $installroot/$distname/$arch");
|
||||
#my $rc = system("cd $path;rsync -a . $installroot/$distname/$arch/");
|
||||
chmod 0755,"$installroot/$distname/$arch";
|
||||
xCAT::Yum->localize_yumrepo($installroot,$distname,$arch);
|
||||
|
@ -13,6 +13,7 @@ use Thread qw(yield);
|
||||
use xCAT::Client submit_request;
|
||||
my $clientselect = new IO::Select;
|
||||
|
||||
my %dispatched_children;
|
||||
use IO::Socket::SSL;
|
||||
my $inet6support;
|
||||
$inet6support=eval { require Socket6 };
|
||||
@ -379,6 +380,9 @@ $SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) {} };
|
||||
$SIG{TERM} = $SIG{INT} = sub {
|
||||
printf("Asked to quit...\n");
|
||||
$quit++;
|
||||
foreach (keys %dispatched_children) {
|
||||
kill 2, $_;
|
||||
}
|
||||
$SIG{ALRM} = sub { exit 0; }; #die "Did not close out in time for 5 second grace period"; };
|
||||
alarm(2);
|
||||
};
|
||||
@ -679,7 +683,6 @@ sub plugin_command {
|
||||
}
|
||||
|
||||
my $dispatch_dnf=0;
|
||||
my %dispatched_children;
|
||||
my $dispatch_cb;
|
||||
my $dispatch_parentfd;
|
||||
sub dispatch_callback {
|
||||
@ -701,7 +704,7 @@ sub dispatch_callback {
|
||||
my $rsp;
|
||||
if ($parselect->can_read(5)) { #block for up to 5 seconds before continuing
|
||||
if ($rsp = <$dispatch_parentfd>) {
|
||||
if ($rsp =~ /die/) {
|
||||
if ($rsp =~ /die/ or $quit) {
|
||||
exit 0;
|
||||
}
|
||||
} else {
|
||||
@ -743,10 +746,10 @@ sub relay_dispatch {
|
||||
}
|
||||
$clientintr=XMLin($clientintr, SuppressEmpty=>undef,ForceArray=>1 );
|
||||
if ($clientintr->{abortcommand}->[0]) {
|
||||
foreach (keys %dispatched_children) {
|
||||
kill 2, $_;
|
||||
}
|
||||
foreach my $cin ($fds->handles) {
|
||||
foreach (keys %dispatched_children) {
|
||||
kill 2, $_;
|
||||
}
|
||||
print $cin "die\n";
|
||||
$fds->remove($cin);
|
||||
close($cin);
|
||||
|
Loading…
Reference in New Issue
Block a user