build: block SIGTTOU before calling tcsetattr() by bnoordhuis · Pull Request #28535 · nodejs/node
added
the
c++
label
Jul 4, 2019
Trott
added
the
author ready
label
Jul 5, 2019pull bot pushed a commit to Mattlk13/node that referenced this pull request
Jul 6, 2019We might be a background job that doesn't own the TTY so block SIGTTOU before making the tcsetattr() call, otherwise that signal suspends us. This is a better fix than PR nodejs#28490 for issue nodejs#28479. Fixes: nodejs#28530 Fixes: nodejs#28479 Refs: nodejs#28490 PR-URL: nodejs#28535 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
targos pushed a commit that referenced this pull request
Jul 20, 2019We might be a background job that doesn't own the TTY so block SIGTTOU before making the tcsetattr() call, otherwise that signal suspends us. This is a better fix than PR #28490 for issue #28479. Fixes: #28530 Fixes: #28479 Refs: #28490 PR-URL: #28535 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
This was referenced
Jul 23, 2019sunshowers added a commit to nextest-rs/nextest that referenced this pull request
Jan 3, 2026When a test spawns an interactive shell (e.g., `zsh -ic`), the shell opens `/dev/tty` directly and calls `tcsetpgrp` to become the foreground process group. When the shell exits, nextest is now in the background. If nextest then tries to restore terminal state via `tcsetattr`, it receives SIGTTOU and gets suspended. The fix is to block SIGTTOU around `tcsetattr` calls using `sigprocmask`. This is a well-established pattern used by: - less: https://github.com/gwsw/less/blob/e77e117/signal.c#L213-L221 - Node.js: nodejs/node#28535 Also adds a test helper binary (`grab-foreground`) that simulates what interactive shells do, and an ignored integration test to verify the fix. The test is currently ignored because it requires a version of nextest with the fix -- we'll un-ignore it once a new version of nextest is out. Fixes: #2878
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters