nixos-container: replace 'kill' command with 'terminate'

My earlier commit to have `nixos-container destroy` use `kill` broke
the `container-imperative` test, see[1]. As suggested by @aszlig,
`machinectl terminate` doesn't have that problem, and is the command
that should have been used to begin with rather then `kill`.

1| 60c6c7bc9a (commitcomment-18478032)
This commit is contained in:
Scott R. Parish 2016-08-03 09:54:19 -07:00
parent d93f917182
commit d6c55c16f6

View File

@ -22,7 +22,7 @@ Usage: nixos-container list
nixos-container destroy <container-name>
nixos-container start <container-name>
nixos-container stop <container-name>
nixos-container kill <container-name> [--signal <signal-specifier>]
nixos-container terminate <container-name>
nixos-container status <container-name>
nixos-container update <container-name> [--config <string>]
nixos-container login <container-name>
@ -189,12 +189,9 @@ sub isContainerRunning {
return $status =~ /ActiveState=active/;
}
sub killContainer {
my @args = ();
push(@args, ("--signal", $signal)) if ($signal ne "");
system("machinectl", "kill", $containerName, @args) == 0
or die "$0: failed to kill container\n";
sub terminateContainer {
system("machinectl", "terminate", $containerName) == 0
or die "$0: failed to terminate container\n";
}
sub stopContainer {
@ -239,8 +236,7 @@ if ($action eq "destroy") {
die "$0: cannot destroy declarative container (remove it from your configuration.nix instead)\n"
unless POSIX::access($confFile, &POSIX::W_OK);
$signal = "SIGKILL";
killContainer if (isContainerRunning);
terminateContainer if (isContainerRunning);
safeRemoveTree($profileDir) if -e $profileDir;
safeRemoveTree($gcRootsDir) if -e $gcRootsDir;
@ -257,8 +253,8 @@ elsif ($action eq "stop") {
stopContainer;
}
elsif ($action eq "kill") {
killContainer;
elsif ($action eq "terminate") {
terminateContainer;
}
elsif ($action eq "status") {