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
SIGHUP signal not raises exit immediately #5381
Comments
This comment was marked as outdated.
This comment was marked as outdated.
JFYI to trace this you can use this message - #5361 (comment) |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Strange. Maybe Mac has some weird rules about where sockets can be. The socket can be anywhere, I just used /tmp/ for an example. Using the Turns out the strace logs are much shorter on Arch Linux (only 250 lines), so I'm attaching them here. Regular alacritty (xonsh closes): single-instance (doesn't close): |
Good catch @FlyingWombat !
And:
Next you can run xonsh in debug mode in IDE, then run |
I got this on mac: # Terminal 1
xonsh --no-rc
# Terminal 2
ps ax | grep 'xonsh --no-rc'
# xonsh pid 100
kill -SIGHUP 100
# Terminal 1
#zsh: hangup xonsh --no-rc
# Terminal 2
ps ax | grep 'xonsh --no-rc'
# xonsh in S (sleep) state and pid is 101 On the second try: # Terminal 1
xonsh --no-rc # pid 123
# Terminal 2
kill -SIGHUP 123
# Terminal 1
# ...
# File "/Users/pc/.local/xonsh-env/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
# return future.result()
# ^^^^^^^^^^^^^^^
# File "/Users/pc/.local/xonsh-env/lib/python3.12/site-packages/prompt_toolkit/application/application.py", line 649, in run_async
# assert not self._is_running, "Application is already running."
#AssertionError: Application is already running.
#Xonsh encountered an issue during launch
#Failback to /bin/zsh It looks like there is no catching and processing SIGHUP signal. PR is welcome! |
I've understood the case:
Lines 47 to 64 in 4a2cfc6
xonsh/xonsh/ptk_shell/shell.py Lines 413 to 414 in 4a2cfc6
We need to pass forward the Nice catch. I will prepare PR to fix this. Thank you for reporting @FlyingWombat ! |
@FlyingWombat could you please try #5399? xpip install -U --force-reinstall git+https://github.com/xonsh/xonsh@sig_exit_fix |
Originally posted by @FlyingWombat in #5399 (comment): Tried this out, and while it is exiting when sent SIGHUP now, it doesn't always exit properly. What I noticed is, after xonsh exits, zsh no longer recognizes Ctrl+C. When
If I do the same thing with bash, zsh is working properly afterwards. |
@FlyingWombat thanks for help! # Terminal 1
# Run iTerm or Alacritty with zsh as default shell
xonsh -DFFF=1
# Terminal 2
ps ax | grep FFF # xonsh pid 123
kill -SIGHUP 123
# Terminal 1
# Return zsh
# Ctrl+C is not working and Mouse Scroll produces `10M35;`
stty sane
# Everything is working It looks that in 5399 I solved exit code issue and xonsh exit is correct but something is needed to restore terminal state. The readline shell type works good after catching signal so we need to fix PTK: # use the latest commit from 5399
xpip install -U --force-reinstall git+https://github.com/xonsh/xonsh@sig_exit_fix
xonsh -st readline |
@FlyingWombat I fixed stty state for ptk, please test again: xpip install -U --force-reinstall git+https://github.com/xonsh/xonsh@sig_exit_fix
# restart xonsh
xonfig
# Git SHA | 5fa579a # https://github.com/xonsh/xonsh/pull/5399/commits |
Exit signals are working with that PR. Thanks for your help! |
### Before Case 1: Handler catches the exit signal and do not pass it forward. As result xonsh could be suspended by OS or crash. Also exit code is wrong. See repeatable examples with SIGHUP in #5381 (comment). Case 2: From bash/zsh as login shell run xonsh. Then send quit signal to xonsh. The terminal state will be broken: disabled SIGINT, mouse pointer produces mouse state codes. ### After Case 1: Xonsh exit normally with right exit code. Fixed #5381 #5304 #5371. Case 2: After exiting with right exit code the state of the terminal is good. ## For community ⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍 comment** --------- Co-authored-by: a <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
I'm not sure if this is an alacritty issue, or a xonsh issue, so I'm starting here.
When using alacritty in single-instance mode, xonsh processes remain if their parent window is closed by the window manager (e.g. Meta+Q for Sway). I've only been able to find this issue when using both alacritty in single-instance mode and xonsh. Alacritty single-instance with Zsh works as expected, alacritty individual instances works with xonsh, and xonsh with foot's single-instance mode works. The issue also does not occur if xonsh has a parent process other than alacritty (e.g. alacritty -> zsh -> xonsh)
Expected Behavior
Xonsh processes should exit when parent window closes.
Current Behavior
Xonsh process remains when parent window is closed.
Steps to Reproduce
export SHELL=$(which xonsh)
if xonsh isn't your default shell.alacritty --socket /tmp/alacritty.sock
alacritty msg --socket /tmp/alacritty.sock create-window
. This creates a new terminal attached to the same instance of alacritty. Notice now there are two xonsh processes attached to the same alacritty process.xonfig
System
Distro: Nixos
WM: Sway 1.9
Alacritty: 0.13.2
For community
⬇️ Please click the 👍 reaction instead of leaving a
+1
or 👍 commentThe text was updated successfully, but these errors were encountered: