Skip to content

Fix: terminal not properly restored on exit + strerr bombing prevention.#73

Merged
gbin merged 3 commits into
masterfrom
gbin/fix_terminal_capture_restore
Oct 24, 2024
Merged

Fix: terminal not properly restored on exit + strerr bombing prevention.#73
gbin merged 3 commits into
masterfrom
gbin/fix_terminal_capture_restore

Conversation

@gbin

@gbin gbin commented Oct 24, 2024

Copy link
Copy Markdown
Collaborator

The terminal issues became a huge pain with the simulators. This should be fixing the corruptions from stderr and retoring the terminal.

…ld be fixing the corruptions from stderr and retoring the terminal.
@gbin gbin changed the title The terminal issues became a huge pain with the simulators. Fix: terminal not properly restored on exit + strerr bombing prevention. Oct 24, 2024
@mik90 mik90 self-requested a review October 24, 2024 21:22
@mik90

mik90 commented Oct 24, 2024

Copy link
Copy Markdown
Collaborator

Just pulled this down and tested it out on my laptop running fedora + bash in the vscode integrated terminal. Exit works well now!

I did test out killall cu-caterpillar (should default to SIGTERM) out of sheer curiosity and rudeness, and it didn't handle that well. It just prints a bunch of ANSI color codes. Not important tho, this is already an improvement

let dev_null_fd = dev_null.as_raw_fd();
let original_stderr_fd = unsafe { dup(2) };
unsafe {
dup2(dev_null_fd, 2);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does the libc create have a constant for stderr or do you have to use 2? If not, could be good to use a var to denote that. I had to double check https://en.wikipedia.org/wiki/File_descriptor

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ha yes, libc::STDERR_FILENO it is

Comment thread components/monitors/cu_consolemon/src/lib.rs Outdated
@gbin gbin merged commit 44b2337 into master Oct 24, 2024
@gbin gbin deleted the gbin/fix_terminal_capture_restore branch October 24, 2024 23:03
@makeecat makeecat added the bug Something isn't working label Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants