-
Notifications
You must be signed in to change notification settings - Fork 81
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
Error when exiting with ^C under some shells #85
Comments
Are you on Linux? I noticed an issue with rschmitt/heatseeker@6b2d27e#diff-a6432244543ebcd356024444b2fe297aR148 I'm not sure why you would only see this on ^C, however. |
It doesn't seem to be related to the newline from stty. On OS X Yosemite, I can reproduce the error when running via |
I just checked and this happens throughout Selecta's entire history. I suspect that it's something like: the shell is seeing the SIGINT first, starts cleaning up, and by the time Selecta sees it the TTY is already gone. But there must be some way to get around that, because fzf (which uses curses) doesn't have this problem. |
@michaelpj, can you try it on the raw_input branch? I changed the stty command to put the terminal in raw mode, which solves the problem for me, and hopefully for you. If that seems to work, I'll merge it to master. (Note that with the version of the command using bash, hitting ^C only kills Selecta, not the whole pipeline. I don't think there's any good way to make ^C send SIGINT to the entire process group, as it normally would, but also fix this bug.) |
Yep, that fixes it for me. Things now work as I expect when running However, running my pipeline it via |
This changes behaviour in some of my scripts, this one for opening a file in vim for example. Previously if I |
I can alter my scripts to account for this easily enough, just thought I'd raise the change in behaviour that some people might be relying on at the moment. |
Yes - on closer inspection that's also what I'm seeing, it's just that in this case I don't actually mind! It looks like the command substitution evaluates to an empty string, rather than killing the caller. |
Yes, the need for two ^Cs is the result of ^C only killing Selecta. Normally, ^C sends SIGINT to the entire foreground process group, which would contain the whole pipeline. With the terminal in raw mode, the ^C just shows up on the TTY and is read by Selecta. Selecta could send SIGINT to its own process group in response to Selecta does a lot of TTY stuff now, and I feel like I understand what it's doing. But signals and process hierarchies aren't my strong point. I'm not sure that an arbitrary process intercepting a |
I created a gist showing a minimal, isolated version of the original problem. I'm still stumped, though. https://gist.github.com/garybernhardt/d496c69bf9e7cc03ddbd |
Well I now know more about subshells than I did at the start of the day. From what I can tell this is a feature of grouping commands in bash so scripts like mine linked above are working as expected. What I should be doing if I want to use a subshell is generate the error myself. However, I've learnt about this all in the last half an hour so there could be nuances I don't know about. |
I just pushed another branch, @gshutler and @michaelpj , can you try the |
👍 |
1 similar comment
👍 |
Merged into master in abee7d3. Thanks for the excellent bug report and help figuring it out. |
I'm able to reproduce this error by running Using the vim integration as documented I can reproduce this error ~75% of the time. |
I'm failing to reproduce it with zsh 5.2 and Ruby 2.3.0, so it must be caused by something sneakier. Can you try the steps below? Note that some of them involve clearing all environment variables, so you'll need to reactivate Ruby 2.3.0 via your ruby version manager unless it's the globally installed version.
|
Interesting, here's what I'm finding:
I'm reporting this back in order to close the loop, but I'll obviously need to investigate further. If you have any ideas, let me know. |
Awesome, that at least gives us a reference point. I think a good next step would be to compare the results of
|
@michaelavila, any update on this? |
This is only happening (for me) with If you have |
Additionally, this doesn't just happen for me on |
@michaelavila thanks for the stty tip, changing to /bin/stty in selecta fixed this for me. |
Glad I could help, though I'm curious what the real solution is. I rely on |
If I run
bash -c 'cat $(ls | selecta)'
and^C
out of theselecta
prompt, then I get the following error:If I try to run this in a
bash
shell directly, then I don't see the error, but my terminal becomes messed up: input stops appearing, but I can still enter commands.I've tried with
--norc --noprofile --noediting --posix
, and that doesn't help.I also see the error when I run
zsh -c 'cat $(ls | selecta)'
, but have no problems running the command directly at azsh
prompt.I don't see this using
sh
on my system (which isdash
).I'm sure this is some weird terminal interaction, but I'm afraid I don't have any more leads than that! In general, it seems to only happen when
selecta
is running inside a command substitution.The text was updated successfully, but these errors were encountered: