-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fish fails to recover terminal with several process runners #8947
Comments
Please give us the output of One possibility is that these things start a subprocess, over which fish has no control, and that restores terminal modes after the main process has exited. AFAIK we can't wait on arbitrary subprocesses, so this would have to be fixed in these things. Note that node at least has a bug open about it restoring tty modes when it has no business doing so: nodejs/node#41143 (yes, the title is the wrong way around). So if yarn ran a node subprocess and that hangs around after yarn itself exits that could manifest like this. (it might be possible for us to grab the terminal earlier, which might instead cause that subprocess to hang once it messes with the terminal). |
The output of
One thing that tripped me up is that --- before.txt 2022-05-12 08:59:26.000000000 +0300
+++ after.txt 2022-05-12 08:59:27.000000000 +0300
@@ -2,8 +2,8 @@
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
-extproc
-iflags: -istrip icrnl -inlcr -igncr -ixon -ixoff ixany imaxbel iutf8
- -ignbrk brkint -inpck -ignpar -parmrk
+iflags: -istrip icrnl -inlcr -igncr ixon -ixoff -ixany imaxbel iutf8
+ -ignbrk brkint -inpck ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf |
So after looking into the node issue, it seems like that's the underlying culprit: if I run the node process with There are a few things that are still unclear to me:
It may be that fish doesn't really have any control here. If that's the case, then feel free to close this issue 🙂 |
The idea is that node changes the modes after we have restored ours. We get no notification that happened, so we can't re-restore them. At least that's the only theory I can come up with.
That's my fault - stty shows the external modes, not the ones we use for fish internally. Those have echo and such enabled because that's the default - programs like cat won't be setting any modes, so they need the simple normal set. You might try Question: Do things go back to normal after you've run one other command? E.g. you run that node thing, that breaks the modes, then you run |
OK, yeah, now we've got lots of differences: --- before.txt 2022-05-12 10:00:00.000000000 +0300
+++ after.txt 2022-05-12 10:00:18.000000000 +0300
@@ -1,13 +1,13 @@
speed 38400 baud; 50 rows; 120 columns;
-lflags: -icanon isig -iexten -echo echoe echok echoke -echonl echoctl
+lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
-extproc
-iflags: -istrip -icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
- -ignbrk brkint -inpck -ignpar -parmrk
+iflags: -istrip icrnl -inlcr -igncr ixon -ixoff -ixany imaxbel iutf8
+ -ignbrk brkint -inpck ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
- stop = ^S; susp = <undef>; time = 0; werase = ^W;
+ stop = ^S; susp = ^Z; time = 0; werase = ^W;
Yes, even pressing enter with no command fixes it (you can see this behavior in my this asciinema). So really what's happening (I'm guessing) is:
So the culprit here really is that these process managers (both Now, is it possible for fish to cover for these buggy process managers? I'm out of my depth here, but there's nothing with process groups/sessions that could be used for this? |
Ah, yeah, what mostly breaks things here is
Not that I'm aware of, no. We already put these things in their own process group, which seems to not be enough to stop it. (I have an issue here with my understanding of process groups, in that I assumed you can only change terminal modes if you are in the controlling pgroup, but that appears to not be the case - either fish wouldn't manage to restore them because it's not yet controlling, or the child wouldn't manage to restore it because it's not controlling anymore. I'd have to read up on this stuff some more) |
As far as I know there's nothing better we can do here, so I'm closing this. If anyone manages to figure out that there's something we can do, we will of course consider it. |
Fish seems to have some problems resetting the terminal when using a variety of process runners.
Steps to reproduce:
yarn install
in the directory.yarn dev
, wait about 10 seconds, press ^C.Alternative steps, to demonstrate that this isn't really about Yarn:
printf "dev:\n command: node_modules/.bin/remix dev\n" > robo.yml
robo dev
, wait about 10 seconds, press ^C.If it went correctly, the terminal is not properly reset and arrow keys produce escape sequences, like in this recording. Pressing enter after the prompt appears will properly restore the terminal.
I'm reporting this as a fish bug because fish generally does try to recover the terminal before printing the prompt, and it's not getting it right in this case. Also, since
yarn
is built with Node androbo
is built with go, so this is a cross-language issue. Note that runningremix dev
directly doesn't trigger this issue, which is why I believe it's related to process runners rather than with remix/node. My suspicion is that the remix process is outputting something during process shutdown, and this is interfering with fish's reset. But why is fish starting its reset before the processes have finished shutting down?Fish version: 3.4.1 • macOS 10.14.6 •
Darwin Ryans-Macbook.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Jun 22 19:37:08 PDT 2021; root:xnu-4903.278.70~1/RELEASE_X86_64 x86_64
The text was updated successfully, but these errors were encountered: