Skip to content

Commit 6b6f7be

Browse files
author
Andy C
committed
Revert "[interactive] Ignore SIGWINCH in the shell."
This reverts commit 3ab4e69.
1 parent 0b4deb8 commit 6b6f7be

File tree

3 files changed

+9
-33
lines changed

3 files changed

+9
-33
lines changed

core/comp_ui.py

-5
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,6 @@ def _GetTerminalWidth(self):
518518

519519
def OnWindowChange(self):
520520
# type: () -> None
521-
"""
522-
Note: SIGWINCH handler in core/pyos.py no longer calls this.
523-
The shell process should probably handle SIGWINCH only when blocked in
524-
readline().
525-
"""
526521
# Only do it for the NEXT completion. The signal handler can be run in
527522
# between arbitrary bytecodes, and we don't want a single completion
528523
# display to be shown with different widths.

core/pyos.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,7 @@ def InitInteractiveShell(self, display):
282282

283283
# Register a callback to receive terminal width changes.
284284
# NOTE: In line_input.c, we turned off rl_catch_sigwinch.
285-
#signal.signal(signal.SIGWINCH, lambda x, y: display.OnWindowChange())
286-
287-
# Disabled because it causes wait builtin to abort (issue 1067)
288-
signal.signal(signal.SIGWINCH, signal.SIG_IGN)
285+
signal.signal(signal.SIGWINCH, lambda x, y: display.OnWindowChange())
289286

290287
def AddUserTrap(self, sig_num, handler):
291288
# type: (int, Any) -> None

test/interactive.py

+8-24
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@ def get_pid_by_name(name):
4242
# XXX: make sure this is restricted to subprocesses under us.
4343
# This could be problematic on the continuous build if many tests are running
4444
# in parallel.
45-
output = pexpect.run('pgrep --exact --newest %s' % name)
45+
output = pexpect.run('pgrep --exact --newest cat')
4646
return int(output.split()[-1])
4747

4848

49-
def send_signal(name, sig_num):
50-
"""Kill the most recent process matching `name`."""
51-
os.kill(get_pid_by_name(name), sig_num)
52-
53-
5449
# XXX: osh.sendcontrol("z") does not suspend the foreground process :(
5550
#
5651
# why does osh.sendcontrol("c") generate SIGINT, while osh.sendcontrol("z")
5752
# appears to do nothing?
5853
def stop_process__hack(name):
5954
"""Send sigstop to the most recent process matching `name`"""
60-
send_signal(name, signal.SIGSTOP)
55+
os.kill(get_pid_by_name(name), signal.SIGSTOP)
56+
57+
58+
def kill_process(name):
59+
"""Kill the most recent process matching `name`."""
60+
os.kill(get_pid_by_name(name), signal.SIGINT)
6161

6262

6363
class InteractiveTest(object):
@@ -119,22 +119,6 @@ def __exit__(self, t, v, tb):
119119

120120

121121
def main(argv):
122-
with InteractiveTest('wait builtin then SIGWINCH (issue 1067)') as osh:
123-
osh.sendline('sleep 1 &')
124-
osh.sendline('wait')
125-
126-
time.sleep(0.1)
127-
128-
# simulate window size change
129-
osh.kill(signal.SIGWINCH)
130-
131-
osh.expect(r'.*\$') # expect prompt
132-
133-
osh.sendline('echo status=$?')
134-
osh.expect('status=0')
135-
136-
#return
137-
138122
with InteractiveTest('Ctrl-C during external command') as osh:
139123
osh.sendline('sleep 5')
140124

@@ -217,7 +201,7 @@ def main(argv):
217201
osh.expect(r".*\$")
218202
osh.sendline("fg")
219203
osh.expect(r"Continue PID \d+")
220-
send_signal("cat", signal.SIGINT)
204+
kill_process("cat")
221205
osh.expect(r".*\$")
222206
osh.sendline("fg")
223207
osh.expect("No job to put in the foreground")

0 commit comments

Comments
 (0)