parent: change create_child interface.

To allow for additional arguments.
This commit is contained in:
David Wilson 2018-04-27 03:50:03 +01:00
parent 1fc7df5be5
commit 1be03eb458
2 changed files with 6 additions and 6 deletions

View File

@ -243,7 +243,7 @@ def create_socketpair():
return parentfp, childfp return parentfp, childfp
def create_child(*args): def create_child(args):
""" """
Create a child process whose stdin/stdout is connected to a socket. Create a child process whose stdin/stdout is connected to a socket.
@ -284,7 +284,7 @@ def _acquire_controlling_tty():
fcntl.ioctl(2, termios.TIOCSCTTY) fcntl.ioctl(2, termios.TIOCSCTTY)
def tty_create_child(*args): def tty_create_child(args):
""" """
Return a file descriptor connected to the master end of a pseudo-terminal, Return a file descriptor connected to the master end of a pseudo-terminal,
whose slave end is connected to stdin/stdout/stderr of a new child process. whose slave end is connected to stdin/stdout/stderr of a new child process.
@ -318,7 +318,7 @@ def tty_create_child(*args):
return proc.pid, master_fd, None return proc.pid, master_fd, None
def hybrid_tty_create_child(*args): def hybrid_tty_create_child(args):
""" """
Like :func:`tty_create_child`, except attach stdin/stdout to a socketpair Like :func:`tty_create_child`, except attach stdin/stdout to a socketpair
like :func:`create_child`, but leave stderr and the controlling TTY like :func:`create_child`, but leave stderr and the controlling TTY
@ -701,7 +701,7 @@ class Stream(mitogen.core.Stream):
def start_child(self): def start_child(self):
args = self.get_boot_command() args = self.get_boot_command()
try: try:
return self.create_child(*args) return self.create_child(args)
except OSError: except OSError:
e = sys.exc_info()[1] e = sys.exc_info()[1]
msg = 'Child start failed: %s. Command was: %s' % (e, Argv(args)) msg = 'Child start failed: %s. Command was: %s' % (e, Argv(args))

View File

@ -117,9 +117,9 @@ class TtyCreateChildTest(unittest2.TestCase):
# read a password. # read a password.
tf = tempfile.NamedTemporaryFile() tf = tempfile.NamedTemporaryFile()
try: try:
pid, fd, _ = self.func( pid, fd, _ = self.func([
'bash', '-c', 'exec 2>%s; echo hi > /dev/tty' % (tf.name,) 'bash', '-c', 'exec 2>%s; echo hi > /dev/tty' % (tf.name,)
) ])
deadline = time.time() + 5.0 deadline = time.time() + 5.0
for line in mitogen.parent.iter_read([fd], deadline): for line in mitogen.parent.iter_read([fd], deadline):
self.assertEquals('hi\n', line) self.assertEquals('hi\n', line)