3 bup_python="$(dirname "$0")/bup-python" || exit $?
4 exec "$bup_python" "$0" ${1+"$@"}
8 from __future__ import absolute_import
9 import os, sys, subprocess, struct
11 from bup import options
12 from bup.helpers import debug1, debug2, mux
13 from bup.io import byte_stream
15 # Give the subcommand exclusive access to stdin.
16 orig_stdin = os.dup(0)
17 devnull = os.open(os.devnull, os.O_RDONLY)
22 bup mux command [arguments...]
25 o = options.Options(optspec)
26 (opt, flags, extra) = o.parse(sys.argv[1:])
28 o.fatal('command is required')
32 debug2('bup mux: starting %r\n' % (extra,))
34 outr, outw = os.pipe()
35 errr, errw = os.pipe()
40 p = subprocess.Popen(subcmd, stdin=orig_stdin, stdout=outw, stderr=errw,
41 close_fds=False, preexec_fn=close_fds)
45 out = byte_stream(sys.stdout)
48 mux(p, out.fileno(), outr, errr)
54 debug1('%s exited with code %d\n' % (extra[0], prv))
56 debug1('bup mux: done\n')