summary refs log tree commit diff
path: root/nixos/modules/virtualisation
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-25 17:04:51 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-25 17:04:51 +0200
commitfec3b75e4bba045178bfb4b9ba1e2aa8c55447f5 (patch)
tree6a30838f0737caccd311c8560c20f86d98318799 /nixos/modules/virtualisation
parentabe9fb340e764c963ece980a5f9a2aba21da5125 (diff)
downloadnixlib-fec3b75e4bba045178bfb4b9ba1e2aa8c55447f5.tar
nixlib-fec3b75e4bba045178bfb4b9ba1e2aa8c55447f5.tar.gz
nixlib-fec3b75e4bba045178bfb4b9ba1e2aa8c55447f5.tar.bz2
nixlib-fec3b75e4bba045178bfb4b9ba1e2aa8c55447f5.tar.lz
nixlib-fec3b75e4bba045178bfb4b9ba1e2aa8c55447f5.tar.xz
nixlib-fec3b75e4bba045178bfb4b9ba1e2aa8c55447f5.tar.zst
nixlib-fec3b75e4bba045178bfb4b9ba1e2aa8c55447f5.zip
Fix ‘nixos-container run’
By default, socat only waits 0.5s for the remote side to finish after
getting EOF on the local side. So don't close the local side, instead
wait for socat to exit when the remote side finishes.

http://hydra.nixos.org/build/10663282
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r--nixos/modules/virtualisation/nixos-container.pl8
1 files changed, 6 insertions, 2 deletions
diff --git a/nixos/modules/virtualisation/nixos-container.pl b/nixos/modules/virtualisation/nixos-container.pl
index 2fd41a340962..8a1e6f927b30 100644
--- a/nixos/modules/virtualisation/nixos-container.pl
+++ b/nixos/modules/virtualisation/nixos-container.pl
@@ -212,18 +212,22 @@ elsif ($action eq "root-login") {
 
 elsif ($action eq "run") {
     shift @ARGV; shift @ARGV;
-    open(SOCAT, "|-", $socat, "unix:$root/var/lib/run-command.socket", "-");
+    my $pid = open(SOCAT, "|-", $socat, "-t0", "-", "unix:$root/var/lib/run-command.socket") or die "$0: cannot start $socat: $!\n";
     print SOCAT join(' ', map { "'$_'" } @ARGV), "\n";
+    flush SOCAT;
+    waitpid($pid, 0);
     close(SOCAT);
 }
 
 elsif ($action eq "set-root-password") {
     # FIXME: don't get password from the command line.
     my $password = $ARGV[2] or die "$0: no password given\n";
-    open(SOCAT, "|-", $socat, "unix:$root/var/lib/run-command.socket", "-");
+    my $pid = open(SOCAT, "|-", $socat, "-t0", "-", "unix:$root/var/lib/run-command.socket") or die "$0: cannot start $socat: $!\n";
     print SOCAT "passwd\n";
     print SOCAT "$password\n";
     print SOCAT "$password\n";
+    flush SOCAT;
+    waitpid($pid, 0);
     close(SOCAT);
 }