You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stty in your config.fish causes externally backgrounded fish instances to stop #5246
Using stty in your config.fish causes background processes to suddenly stop.
To reproduce the issue add to your config.fish the following code.
stty werase undef
Then send any job to the background using &.
$ fish -c"echo"&
Job 1, 'fish -c "echo" &' has stopped
Running jobs tells me:
Job Group State Command1 83624 stopped fish -c "echo" &
I can bring the process to the foreground using fg to finish it.
$ fg
Send job 1, 'fish -c "echo" &' to foreground
stty: tcsetattr: Interrupted system call
I know that wrapping the stty command like so:
ifstatus--is-interactive
...
end
...will prevent the issue, but it's unfriendly to tell people how to write their configuration.
This issue was discovered by @tyilo while using jorgebucaran/fisher (see jorgebucaran/fisher#469). The presence of stty in their configuration causes fisher to hang because fisher keeps waiting for a process that is stopped.
I've been able to reproduce this issue on macOS, Linux (Arch) / xterm-256color running fish 2.0.0, 2.2.0, 2.7.1, and the latest fish from HEAD.
changed the title [-]stty in your config.fish causes background processes to suddenly stop[/-][+]stty in your config.fish causes in-session background processes to suddenly stop[/+]on Oct 11, 2018
changed the title [-]stty in your config.fish causes in-session background processes to suddenly stop[/-][+]stty in your config.fish causes externally backgrounded fish instances to stop[/+]on Oct 13, 2018
It's not stty, it's anything that needs to read/write from/to the terminal. Adding cat to your config.fish and then trying to run it in the background does the same.
I'm not sure this is a bug? It's a backgrounded process (i.e. a process that does NOT have control of the terminal) trying to access the terminal, it's going to SIGTTOU or SIGTTIN until it's brought to the foreground and given control of the shell. What do you expect to happen?
This issue was discovered by @tyilo with Fisher (see jorgebucaran/fisher#469). The presence of stty in their configuration causes fisher to hang because fisher keeps waiting for a process that is stopped.
Fisher is not doing anything with stty. Fisher forks fish in the background for each package is trying to download, enabling concurrent downloads.
The problem is the user is/was using stty in their config.fish. And using stty in config.fish will cause backgrounded fish instances to stop / hang.
@mqudsi It's not stty, it's anything that needs to read/write from/to the terminal.
Thanks for the clarification. Is there any way to solve this? Should I tell users (albeit less casually) "Please do not put stty in your config.fish or something along those lines?
@jorgebucaran I just want to make sure you're clear that it's not strictly an "stty in config.fish" issue. Any process that attempts to modify or read from the terminal is going to run into the same issue, although perhaps stty is special because people don't realize it's doing if they're not clear on how it works internally.
@faho@zanchey@ridiculousfish just a thought here, but what if we started shipping config.fish with something like the following:
# Place general fish and environment configuration here:# Anything beyond this point is not executed when fish isn't run interactively, # such as via `fish -c '...'`ifnotstatus--is-interactiveexitend# Place any external commands or commands modifying the behavior of terminal IO here
@jorgebucaran why don’t you fork fish without a home directory or with a known configuration? That way you don’t need to work about the user doing anything untoward.
@faho@zanchey@ridiculousfish just a thought here, but what if we started shipping config.fish with something like the following:
I've considered not reading configuration if we're not interactive, but that would probably break the fisher code here (if it uses a function defined in a snippet).
Even if we added that bit, I don't think users will get that stty touches the terminal, or that touching the terminal is bad if you're in the background. I don't think this particular user even knew what that was - this specific invocation did precisely nothing in fish.
So that warning about "terminal IO" won't really help much.
Could you elaborate a bit more? I'm don't see why. thinking
If we don't source the configuration - neither config.fish, nor conf.d snippets - then you can't use the functions and variables defined there. So you'd be restricted in the kind of thing you could call in fish -c.
Perhaps he had a valid use case?
Because that call is something that's useful in bash. My guess is they just copied it over.
Yes, my idea was to explicitly skip the configuration file then source a "fisher jail configuration" that would allow you to set up an environment that would do what you need and load any functions, etc. necessary to proceed with the operation. It's more work to get started but it'd be entirely deterministic.
There's (currently) no command-line option to skip the user's config.fish (although it might be a good idea), but depending on what you execute you may be able to get away with redefining HOME before launching fish.
env HOME=/dev/null fish /path/to/fisher_download_script.fish &
will execute without a user-modified configuration and without any "known" configuration. To instead use a custom fisher environment, you can point HOME to a pre-installed directory containing whatever functions your fisher scripts need in a .config/fish/functions subdirectory of that directory.
Make sure to restore HOME for any external commands you run within your script, though!
@mqudsi or @faho Could you summarize the position of the fish-shell developers regarding this issue (for future reference)? Poorly informed users like @tyilo may conclude that what is happening here is a problem in Fisher's end, when in fact it isn't.
Could you summarize the position of the fish-shell developers regarding this issue (for future reference)?
My "position" is that currently, you need to guard all commands that "touch the terminal" (that means they produce output or try to fiddle with the terminal settings) with status is-interactive.
We're open to changes here. A few possibilities:
Don't read configuration if not interactive (might be too restrictive?)
Add a commandline-option to start fish without configuration (means you need to use it)
Don't allow configuration access to the terminal if not interactive (half-baked)
But until then, not guarding is a user error.
Reacted by Jorge Bucaran, Peter Ammon and David Adam
Activity
mqudsi commentedon Oct 11, 2018
This is unfortunate since explicitly using stty in config.fish is the current workaround to #2980.
As an aside, the title made me understand that it breaks background jobs within the session, not externally backgrounded fish runs.
[-]stty in your config.fish causes background processes to suddenly stop[/-][+]stty in your config.fish causes in-session background processes to suddenly stop[/+]jorgebucaran commentedon Oct 11, 2018
Thanks for having a look @mqudsi. I've updated the title.
[-]stty in your config.fish causes in-session background processes to suddenly stop[/-][+]stty in your config.fish causes externally backgrounded fish instances to stop[/+]mqudsi commentedon Oct 31, 2018
It's not
stty, it's anything that needs to read/write from/to the terminal. Addingcatto yourconfig.fishand then trying to run it in the background does the same.I'm not sure this is a bug? It's a backgrounded process (i.e. a process that does NOT have control of the terminal) trying to access the terminal, it's going to
SIGTTOUorSIGTTINuntil it's brought to the foreground and given control of the shell. What do you expect to happen?mqudsi commentedon Oct 31, 2018
Additionally, this is really independent of
config.fish, even. Try runningfish -c 'cat' &in a terminal, and you'll see the same behavior:or even bash:
jorgebucaran commentedon Oct 31, 2018
@mqudsi The backgrounded process is not created in
config.fish.mqudsi commentedon Oct 31, 2018
I don't understand, can you explain what you mean? stty is being run as part of the background fish instance, isn't it?
jorgebucaran commentedon Oct 31, 2018
Fisher is not doing anything with
stty. Fisher forksfishin the background for each package is trying to download, enabling concurrent downloads.The problem is the user is/was using
sttyin theirconfig.fish. And usingsttyinconfig.fishwill cause backgrounded fish instances to stop / hang.cc @mqudsi
jorgebucaran commentedon Oct 31, 2018
Thanks for the clarification. Is there any way to solve this? Should I tell users (albeit less casually) "Please do not put
sttyin yourconfig.fishor something along those lines?mqudsi commentedon Oct 31, 2018
@jorgebucaran I just want to make sure you're clear that it's not strictly an "
sttyinconfig.fish" issue. Any process that attempts to modify or read from the terminal is going to run into the same issue, although perhapssttyis special because people don't realize it's doing if they're not clear on how it works internally.@faho @zanchey @ridiculousfish just a thought here, but what if we started shipping
config.fishwith something like the following:jorgebucaran commentedon Oct 31, 2018
@mqudsi Once again thanks for the clarification :)
mqudsi commentedon Oct 31, 2018
@jorgebucaran why don’t you fork fish without a home directory or with a known configuration? That way you don’t need to work about the user doing anything untoward.
jorgebucaran commentedon Oct 31, 2018
How? 👀
Maybe that'll create new problems, but it's worth looking into.
faho commentedon Oct 31, 2018
I've considered not reading configuration if we're not interactive, but that would probably break the fisher code here (if it uses a function defined in a snippet).
Even if we added that bit, I don't think users will get that
sttytouches the terminal, or that touching the terminal is bad if you're in the background. I don't think this particular user even knew what that was - this specific invocation did precisely nothing in fish.So that warning about "terminal IO" won't really help much.
jorgebucaran commentedon Oct 31, 2018
Could you elaborate a bit more? I'm don't see why. 🤔
Actually, in all this time, I never took a moment to ask @tyilo: why where you using
sttyin your config.fish? Just curious.Perhaps he had a valid use case?
faho commentedon Oct 31, 2018
If we don't source the configuration - neither config.fish, nor conf.d snippets - then you can't use the functions and variables defined there. So you'd be restricted in the kind of thing you could call in
fish -c.Because that call is something that's useful in bash. My guess is they just copied it over.
jorgebucaran commentedon Oct 31, 2018
Interesting. I didn't know this would mean not sourcing configuration snippets.
mqudsi commentedon Oct 31, 2018
Yes, my idea was to explicitly skip the configuration file then source a "fisher jail configuration" that would allow you to set up an environment that would do what you need and load any functions, etc. necessary to proceed with the operation. It's more work to get started but it'd be entirely deterministic.
jorgebucaran commentedon Nov 1, 2018
How?
mqudsi commentedon Nov 1, 2018
There's (currently) no command-line option to skip the user's
config.fish(although it might be a good idea), but depending on what you execute you may be able to get away with redefiningHOMEbefore launching fish.will execute without a user-modified configuration and without any "known" configuration. To instead use a custom fisher environment, you can point
HOMEto a pre-installed directory containing whatever functions your fisher scripts need in a.config/fish/functionssubdirectory of that directory.Make sure to restore
HOMEfor any external commands you run within your script, though!jorgebucaran commentedon Nov 1, 2018
Thanks, @mqudsi. I'll definitely try it out.
jorgebucaran commentedon Nov 15, 2018
@mqudsi or @faho Could you summarize the position of the fish-shell developers regarding this issue (for future reference)? Poorly informed users like @tyilo may conclude that what is happening here is a problem in Fisher's end, when in fact it isn't.
faho commentedon Nov 16, 2018
My "position" is that currently, you need to guard all commands that "touch the terminal" (that means they produce output or try to fiddle with the terminal settings) with
status is-interactive.We're open to changes here. A few possibilities:
Don't read configuration if not interactive (might be too restrictive?)
Add a commandline-option to start fish without configuration (means you need to use it)
Don't allow configuration access to the terminal if not interactive (half-baked)
But until then, not guarding is a user error.