tty: tty.WriteStream event 'resize' on Windows #13197
Copy link
Copy link
Closed
Labels
docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.ttyIssues and PRs related to the tty subsystem.Issues and PRs related to the tty subsystem.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.wslIssues and PRs related to the Windows Subsystem for Linux.Issues and PRs related to the Windows Subsystem for Linux.
Description
- Version: 8.0.0 rc1
- Platform: Windows 7 x64
- Subsystem: tty
Is this event supported on Windows?
The script with this code from the doc exits immediately without launching the event loop. I've tried to modify it like this:
process.stdout.on('resize', () => {
console.log('screen size has changed!');
console.log(`${process.stdout.columns}x${process.stdout.rows}`);
});
setInterval(()=>{}, 1000);and then to resize the console window manually or via the console window properties, but the event handler never fired.
Reacted by Refael Ackermann and Sindre Sorhus
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.ttyIssues and PRs related to the tty subsystem.Issues and PRs related to the tty subsystem.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.wslIssues and PRs related to the Windows Subsystem for Linux.Issues and PRs related to the Windows Subsystem for Linux.
Activity
refack commentedon May 24, 2017
Quick answer currently no. It depends on
SIGWINCHwhich comes from [g]libc.Maybe possible to implement https://stackoverflow.com/questions/10856926/sigwinch-equivalent-on-windows
Definalty need to document
mscdex commentedon May 24, 2017
Perhaps it's supported in WSL?
vsemozhetbyt commentedon May 24, 2017
FWIW, I've tried on Git Bash for Windows with the same result.
refack commentedon May 24, 2017
Do you know if WSL has signals?
refack commentedon May 24, 2017
WSL works for me (with node

v7.10for ubuntu on Windows 10 15063)But that isn't fair...
richardlau commentedon May 27, 2017
libuv emulates
SIGWINCHon Windows: http://docs.libuv.org/en/v1.x/signal.htmlvsemozhetbyt commentedon May 27, 2017
@richardlau This variant with a possibility to move cursor also does not work:
And the event handler by itself does not launch event loop, so it is hardly processed.
Could we document this? I am not sure about wording and details.
Fishrock123 commentedon May 29, 2017
@vsemozhetbyt sounds like the correct course of action
refack commentedon May 29, 2017
@richardlau do we need to move the cursor in a special way? Because the following does not fire. And
console.log(`${process.stdout.columns} X ${process.stdout.rows}`);keeps outputing the initial values.richardlau commentedon May 30, 2017
I have no idea; I just remembered that
SIGWINCHwas specifically mentioned in the libuv docs and quoted the reference.bzoz commentedon Jun 8, 2017
The console needs to be in raw mode for this to work (mind, this will not exit after ctrl-c):
I guess an doc update should be made.
vsemozhetbyt commentedon Jun 8, 2017
@bzoz With this code, the event is processed when I change the size via terminal options but is ignored when I change the size manually. This is true for cmd.exe. For the git bash for Windows, manual width change fires the event, height change is ignored.
win,tty: improve SIGWINCH support
doc: note 'resize' event conditions on Windows
doc: note 'resize' event conditions on Windows
doc: note 'resize' event conditions on Windows
doc: note 'resize' event conditions on Windows
win,tty: improve SIGWINCH support
win,tty: improve SIGWINCH support
win,tty: improve SIGWINCH support
doc: note 'resize' event conditions on Windows
doc: note 'resize' event conditions on Windows
win,tty: improve SIGWINCH support
win,tty: improve SIGWINCH support