MCPcopy Create free account
hub / github.com/apache/mesos / popen_tty

Function popen_tty

src/python/cli_new/lib/cli/tests/base.py:481–504  ·  view source on GitHub ↗

Open a process with stdin connected to a pseudo-tty. :param cmd: command to run :type cmd: str :returns: (Popen, master) tuple, where master is the master side of the of the tty-pair. It is the responsibility of the caller to close the master fd, and to perform any c

(cmd, shell=True)

Source from the content-addressed store, hash-verified

479
480
481def popen_tty(cmd, shell=True):
482 """
483 Open a process with stdin connected to a pseudo-tty.
484
485 :param cmd: command to run
486 :type cmd: str
487 :returns: (Popen, master) tuple, where master is the master side
488 of the of the tty-pair. It is the responsibility of the caller
489 to close the master fd, and to perform any cleanup (including
490 waiting for completion) of the Popen object.
491 :rtype: (Popen, int)
492 """
493 master, slave = pty.openpty()
494 # pylint: disable=subprocess-popen-preexec-fn
495 proc = subprocess.Popen(cmd,
496 stdin=slave,
497 stdout=subprocess.PIPE,
498 stderr=subprocess.PIPE,
499 preexec_fn=os.setsid,
500 close_fds=True,
501 shell=shell)
502 os.close(slave)
503
504 return (proc, master)
505
506
507def wait_for_task(master, name, state, delay=1):

Callers

nothing calls this directly

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected