From: Rob Browning Date: Tue, 11 Nov 2014 22:23:22 +0000 (-0600) Subject: mux: give stdin exclusively to subcommand X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=408d5c2504ebfe6888548fd1974ca1f18511d4f9;p=packages%2Fb%2Fbup.git mux: give stdin exclusively to subcommand Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/cmd/mux-cmd.py b/cmd/mux-cmd.py index 332d7bd..b70c0a8 100755 --- a/cmd/mux-cmd.py +++ b/cmd/mux-cmd.py @@ -3,6 +3,12 @@ import os, sys, subprocess, struct from bup import options from bup.helpers import * +# Give the subcommand exclusive access to stdin. +orig_stdin = os.dup(0) +devnull = os.open('/dev/null', os.O_RDONLY) +os.dup2(devnull, 0) +os.close(devnull) + optspec = """ bup mux command [arguments...] -- @@ -21,7 +27,9 @@ errr, errw = os.pipe() def close_fds(): os.close(outr) os.close(errr) -p = subprocess.Popen(subcmd, stdout=outw, stderr=errw, preexec_fn=close_fds) + +p = subprocess.Popen(subcmd, stdin=orig_stdin, stdout=outw, stderr=errw, + preexec_fn=close_fds) os.close(outw) os.close(errw) sys.stdout.write('BUPMUX')