From d6c55c16f6f2305a853c94239bf8b1162fd36556 Mon Sep 17 00:00:00 2001 From: "Scott R. Parish" Date: Wed, 3 Aug 2016 09:54:19 -0700 Subject: [PATCH] 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| https://github.com/NixOS/nixpkgs/commit/60c6c7bc9a0d564cf86af4b1711b33db48cf0d07#commitcomment-18478032 --- .../nixos-container/nixos-container.pl | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pkgs/tools/virtualization/nixos-container/nixos-container.pl b/pkgs/tools/virtualization/nixos-container/nixos-container.pl index a4b6f11654e8..01ce00e8cb75 100755 --- a/pkgs/tools/virtualization/nixos-container/nixos-container.pl +++ b/pkgs/tools/virtualization/nixos-container/nixos-container.pl @@ -22,7 +22,7 @@ Usage: nixos-container list nixos-container destroy nixos-container start nixos-container stop - nixos-container kill [--signal ] + nixos-container terminate nixos-container status nixos-container update [--config ] nixos-container login @@ -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") {