Skip to content

Commit af9d848

Browse files
committed
Remove preexec_fn from subprocess call in console_io.py
PiperOrigin-RevId: 304646913 Change-Id: I16b76e90490984fd9f751823bf1304d75eb087a0
1 parent 61785e6 commit af9d848

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

fire/console/console_io.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ def IsInteractive(output=False, error=False, heuristic=False):
6969
return True
7070

7171

72-
def PreexecFunc():
73-
signal.signal(signal.SIGINT, signal.SIG_IGN)
74-
75-
7672
def More(contents, out, prompt=None, check_pager=True):
7773
"""Run a user specified pager or fall back to the internal pager.
7874
@@ -102,18 +98,14 @@ def More(contents, out, prompt=None, check_pager=True):
10298
less_orig = encoding.GetEncodedValue(os.environ, 'LESS', None)
10399
less = '-R' + (less_orig or '')
104100
encoding.SetEncodedValue(os.environ, 'LESS', less)
105-
# Ignores SIGINT from this point on since the child process has started
106-
# and we don't want to terminate either one when the child is still alive.
101+
# Ignore SIGINT while the pager is running.
102+
# We don't want to terminate the parent while the child is still alive.
107103
signal.signal(signal.SIGINT, signal.SIG_IGN)
108-
# Runs PreexecFunc before starting the child so SIGINT is ignored for the
109-
# child process as well.
110-
p = subprocess.Popen(
111-
pager, stdin=subprocess.PIPE, shell=True, preexec_fn=PreexecFunc)
104+
p = subprocess.Popen(pager, stdin=subprocess.PIPE, shell=True)
112105
enc = console_attr.GetConsoleAttr().GetEncoding()
113106
p.communicate(input=contents.encode(enc))
114107
p.wait()
115-
# Starts using default disposition for SIGINT again after the child has
116-
# exited.
108+
# Start using default signal handling for SIGINT again.
117109
signal.signal(signal.SIGINT, signal.SIG_DFL)
118110
if less_orig is None:
119111
encoding.SetEncodedValue(os.environ, 'LESS', None)

0 commit comments

Comments
 (0)