Skip to content

devpts: Check ISIG flag before generating signals for VINTR/VSUSP/VQUIT#12786

Merged
copybara-service[bot] merged 1 commit intogoogle:masterfrom
tanyifeng:devpts-isig-check
Mar 25, 2026
Merged

devpts: Check ISIG flag before generating signals for VINTR/VSUSP/VQUIT#12786
copybara-service[bot] merged 1 commit intogoogle:masterfrom
tanyifeng:devpts-isig-check

Conversation

@tanyifeng
Copy link
Copy Markdown
Contributor

Signal characters (Ctrl-C/Z/) unconditionally generated signals regardless of the ISIG flag. Linux only generates these signals when L_ISIG(tty) is true (n_tty.c:n_tty_receive_char_special).

Also fix signal characters leaking into the read buffer — Linux consumes them in n_tty_receive_signal_char() and never delivers them to the reading process.

Signal characters (Ctrl-C/Z/\) unconditionally generated signals
regardless of the ISIG flag. Linux only generates these signals when
L_ISIG(tty) is true (n_tty.c:n_tty_receive_char_special).

Also fix signal characters leaking into the read buffer — Linux
consumes them in n_tty_receive_signal_char() and never delivers
them to the reading process.

Signed-off-by: Tan Yifeng <yiftan@tencent.com>
@tanyifeng
Copy link
Copy Markdown
Contributor Author

The babi text editor's test suite reproduces this issue out of the box. Its [tmux]-parameterized tests in tests/features/replace_test.py send Ctrl-\ (0x1c) through a real PTY via tmux. Without the fix, gVisor unconditionally generates SIGQUIT for Ctrl-\ regardless of the ISIG setting, killing the tmux session.

Run a single test case to reproduce quickly:

docker run --rm --runtime=runsc python:3.11-slim bash -c "
  apt-get update -qq && apt-get install -y -qq tmux git > /dev/null 2>&1 &&
  pip install -q pytest hecate coverage covdefaults &&
  git clone --depth 1 https://github.com/asottile/babi.git /tmp/babi &&
  cd /tmp/babi && pip install -e . -q &&
  python -m pytest tests/features/replace_test.py -k 'test_replace_cancel[tmux-Enter]' --no-header -rN --tb=line
"

Before fix — FAILED (Ctrl-\ generates SIGQUIT, killing tmux server):

E   subprocess.CalledProcessError: Command '['tmux', '-u', '-L', '51fd4b4d2a5022ff', 'list-buffers']' returned non-zero exit status 1.
================= 1 failed, 51 deselected, 1 warning in 5.42s ==================

After fix — PASSED (Ctrl-\ passed as data byte 0x1c to babi):

================= 1 passed, 51 deselected, 1 warning in 4.71s ==================

Copy link
Copy Markdown
Collaborator

@ayushr2 ayushr2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

copybara-service Bot pushed a commit that referenced this pull request Mar 25, 2026
Signal characters (Ctrl-C/Z/\) unconditionally generated signals regardless of the ISIG flag. Linux only generates these signals when L_ISIG(tty) is true (n_tty.c:n_tty_receive_char_special).

Also fix signal characters leaking into the read buffer — Linux consumes them in n_tty_receive_signal_char() and never delivers them to the reading process.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12786 from tanyifeng:devpts-isig-check 0a1922c
PiperOrigin-RevId: 889267158
copybara-service Bot pushed a commit that referenced this pull request Mar 25, 2026
Signal characters (Ctrl-C/Z/\) unconditionally generated signals regardless of the ISIG flag. Linux only generates these signals when L_ISIG(tty) is true (n_tty.c:n_tty_receive_char_special).

Also fix signal characters leaking into the read buffer — Linux consumes them in n_tty_receive_signal_char() and never delivers them to the reading process.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12786 from tanyifeng:devpts-isig-check 0a1922c
PiperOrigin-RevId: 889267158
@copybara-service copybara-service Bot merged commit e99e98c into google:master Mar 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants