tolerate 'batch' systems that mess with stdin (#23596)

* tolerate 'batch' systems taht mess with stdin

fixes #23541

* have pause on windows tolerate devnull

* tuplie

(cherry picked from commit 586fcae398)
pull/23994/head
Brian Coca 8 years ago committed by Brian Coca
parent 39ce8c6610
commit 3e9d4607ce

@ -77,6 +77,7 @@ class WorkerProcess(multiprocessing.Process):
self._variable_manager = variable_manager self._variable_manager = variable_manager
self._shared_loader_obj = shared_loader_obj self._shared_loader_obj = shared_loader_obj
if sys.stdin.isatty():
# dupe stdin, if we have one # dupe stdin, if we have one
self._new_stdin = sys.stdin self._new_stdin = sys.stdin
try: try:
@ -89,9 +90,12 @@ class WorkerProcess(multiprocessing.Process):
# not a valid file descriptor, so we just rely on # not a valid file descriptor, so we just rely on
# using the one that was passed in # using the one that was passed in
pass pass
except ValueError: except (AttributeError, ValueError):
# couldn't get stdin's fileno, so we just carry on # couldn't get stdin's fileno, so we just carry on
pass pass
else:
# set to /dev/null
self._new_stdin = os.devnull
def run(self): def run(self):
''' '''

@ -123,8 +123,9 @@ class ActionModule(ActionBase):
fd = None fd = None
try: try:
fd = self._connection._new_stdin.fileno() fd = self._connection._new_stdin.fileno()
except ValueError: except (ValueError, AttributeError):
# someone is using a closed file descriptor as stdin # ValueError: someone is using a closed file descriptor as stdin
# AttributeError: someone is using a null file descriptor as stdin on windoez
pass pass
if fd is not None: if fd is not None:
if isatty(fd): if isatty(fd):

Loading…
Cancel
Save