nodejs / nodejs/node

Node doesn't reset tty on early/aborted exit

Đang mở
#41,143 17 bình luận 3 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

tty
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.4k
Merge trung bình
4 ngày 3 giờ
Pull request đã merge (30 ngày)
272

Mô tả

Version

v16.13.1, v17.2.0 tested

Platform

Linux lux0 5.11.22-100.fc32.x86_64 #1 SMP Wed May 19 18:58:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Create this script file in test.js:

#!/usr/bin/env node
for (let i = 0; i < 100000; i++) {
console.log("i:", i)
}

In a shell window, run:

test.js |less

Hit "q" to quit less (after only one page of output), which also kills test.js while it still has undelivered data in the stdout buffer.

Your tty will be left in raw mode (no echo, other command characters disabled). Must do a "stty sane" to restore usability of the console.

How often does it reproduce? Is there a required condition?

Happens every time. Have tested multiple versions of node on Linux and MacOS.

What is the expected behavior?

Should restore my tty settings no matter how ugly the exit conditions.

What do you see instead?

Tty is left in raw mode with no echo. Can't see my typed commands.

Additional information

Is there a standard way of dealing with this in case a script is killed before it can write its output? Or is this a bug in node?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện báo cáo với script test.js và test.js | less, sau đó kiểm tra cách Node.js xử lý trạng thái terminal khi tiến trình thoát do bị hủy hoặc thoát sớm. Bổ sung kiểm thử hồi quy cho việc thoát khỏi less trong khi đầu ra vẫn còn được đệm, và xác minh rằng tty trở về trạng thái bình thường mà không cần stty sane.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
cli, operating-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.