Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset terminal attributes after exit #20

Open
aarondill opened this issue Jul 12, 2023 · 9 comments · May be fixed by #50
Open

Reset terminal attributes after exit #20

aarondill opened this issue Jul 12, 2023 · 9 comments · May be fixed by #50
Labels
bug Something isn't working help wanted Extra attention is needed wezterm Issue specific to wezterm

Comments

@aarondill
Copy link

aarondill commented Jul 12, 2023

Issue:
After exiting awrit (using pkill awrit bc ctrl+c doesn't work for me 😞), moving the mouse results in escape codes being written to the terminal. This is fixed by a tput reset.

Expected behavior:
awrit sets the terminal attributes to their previous values, or if impossible, then resets them to default (essentially tput reset)

Environment:
wezterm 20230712-072601-f4abf8fd on Ubuntu 22.04.2 LTS

@AnonymouX47
Copy link

AnonymouX47 commented Jul 12, 2023

Not sure if there's a particular key binding to exit "properly" but pkill -2 awrit should send SIGINT (as ctrl + c does) instead of SIGTERM sent by pkill awrit.

EDIT: Default is SIGTERM, not SIGKILL.

@chase
Copy link
Owner

chase commented Jul 13, 2023

Hm, strange that Ctrl+C stopped working. If you want to play around with it, the intercept code is here: https://github.com/chase/awrit/blob/main/awrit/input_event_handler.cc#L23-L30

Realistically, awrit should have a signal handler to handle any terminating event and exit cleanly.

I'm rather busy for a while so I can't put time into this right now, but if you figure out a fix for this I'll gladly accept a PR

@aarondill
Copy link
Author

Not sure if there's a particular key binding to exit "properly" but pkill -2 awrit should send SIGINT (as ctrl + c does) instead of SIGKILL sent by pkill awrit.

According to man pkill:

       pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.

While SIGTERM is not the same as SIGINT, they should both be handled (nearly) identically by every program, and unlike SIGKILL can and should be caught before cleanup.

Infact, it seems to be caught and handled the same as SIGINT here, which means any signal that is passed will be treated identically. It seems that it just doesn't reset terminal attributes?

@AnonymouX47
Copy link

AnonymouX47 commented Jul 13, 2023

According to man pkill:

       pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.

Sorry, that was an error on my part. Corrected it.

Infact, it seems to be caught and handled the same as SIGINT here, which means any signal that is passed will be treated identically. It seems that it just doesn't reset terminal attributes?

Oh, I see... thanks.

@chase chase added bug Something isn't working help wanted Extra attention is needed labels Jul 14, 2023
@chase chase added the wezterm Issue specific to wezterm label Aug 17, 2023
@chase
Copy link
Owner

chase commented Aug 17, 2023

I just made a fresh build and I can't reproduce this issue in Kitty. It correctly resets the terminal attributes.

I believe this might be a wezterm-specific issue. While wezterm should mostly work, there are bound to be issues like this that arise since I primarily use and test things in Kitty.


Detecting if things are running in wezterm and apply additional fixes is probably the best we can do in this case.
I'm still busy unfortunately, so I'd appreciate any PRs, hacky or not 🙂

@metamaterialsuit
Copy link

I also was having problems with ctrl+c -- turns out, doing ctrl+c + c (ctrl+c followed by another c while holding ctrl) works. I don't know why that's happening.

@Parsifa1
Copy link

in ghostty, if i use ctrl-c to kill the awrit, the terminal cursor will dispeared. i think these maybe the same problem.

@rustbuckett
Copy link

I'm not able to exit awrit using ctrl+c, nor ctrl+c+c. I have to close the window/pane and recreate it. Using kitty 0.36.4.

Other than that, this is super cool for my environment!!

@goproslowyo
Copy link

@rockorager / @rustbuckett I tested out #50 and it works great with Ghostty. Seemingly doesn't fix Kitty though YMMV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed wezterm Issue specific to wezterm
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants