-
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
warn if exiting fish when background jobs exist #3497
Comments
How do you exit the shell if you have a job running in the foreground? As for the case of jobs in the background a warning by itself doesn't seem very useful. Presumably you also intend that fish ask the user if they really want to exit with jobs in the background and require an answer in the affirmative before actually exiting. I'm ambivalent about adding that behavior since it's paternalistic and there's a good chance I deliberately want the backgrounded jobs to continue running. |
We kind of are a paternalistic shell, though I prefer "friendly". |
Nobody really wants those background jobs to keep running. Managing processes is better served via a systemd unit. The friendly thing to do would seem to be to display a warning (no ask) and quit if exiting a second time. What do bash and zsh do? Do people use htop that much? It's not even useful when chromium children is 99% of what's in there. |
I think saying "nobody really wants..." is a bit strong. I certainly want that behavior but then I'm a grey beard who has been using UNIX three decades and am definitely not the typical fish user. I switched from zsh and remember it asking me to type |
Just to be clear, this is already a thing, in fish, for suspended jobs. It seems right to extend it to stopped ones as well. |
I agree. |
I think this regressed in #111. ZSH kills background jobs by default when exiting. The user is forced to use If we can maintain the same behavior as ZSH in this regard that would be great. |
Fish was deliberately changed 1.6 years ago to not kill background jobs in issue #1771 because two people expressed displeasure with the behavior. We can, and should, display a warning and require the user to type @zanchey: You made the change that resulted in the behavior being discussed. Care to comment? |
I am still interested in feedback from @zanchey, or anyone else, as to why the current behavior is preferable to bash/zsh/etcetera regarding background jobs of an interactive fish shell. Nonetheless I am going to create a PR that makes fish behave like those shells and reverts the change made in response to issue #1771. |
I like that. |
In an attempt to defend a change from a couple of years ago, I think what I was hoping to do is file off one of the more surprising behaviours of POSIX shells - the sudden disappearance of processes which aren't obviously under the shell's direct control. Fish is supposed to be friendly, but (having thought about it some more), I think friendliness involves explaining what is happening rather than insulating users from potentially-unwanted behaviour. I've made some more comments in #3658. |
Er, I do. This change breaks my workflow (obligatory https://xkcd.com/1172/): when I start my session, I tend to run I could not find a fish equivalent to zsh’s The warning does say that the processes will be killed with a second |
@spider-mario: Use
Thanks for the feedback but this won't be reverted to the old behavior. The current behavior is friendlier to people who aren't shell power users and are surprised to find processes they backgrounded still running after they exit the shell. And while fish deliberately breaks from Posix 1003.1 in several ways there is no good reason to be different with respect to this particular behavior. Power users like yourself can easily work around it. For example create your own disown command by creating a file named ~/.config/fish/functions/disown.fish with this content:
|
I know about redirecting the output of nohup, which is why I said “it’s quite a bit more verbose, especially if I don’t want a |
@spider-mario: Please open an enhancement request. |
Turns out |
😢 |
Why the long face? |
I would like some advice on how to deal with this change in behavior. I have a very strong habit and very frequently start GUI applications from fish doing such things as emacs &; firefox &; pavucontrol &; mupdf mydoc.pdf & It is also my understanding that that the recommended course of action is to use nohup or define a fish function that uses nohup to launch these GUI applications. However I can't use tab completion that way because the real command is the second word on the command line. Any advice is welcome. |
Your sentence is ambiguous but, yes, that is true. The problem is that if you kill the shell via SIGHUP then those processes are not kept running. Even in bash. The inconsistency causes more problems than it solves. Fish used to be consistent in how it handled the two cases, then wasn't consistent for 1.5 years, and is once again consistent. The long term solution is for someone to take the time to address issue #2810 and implement a
Although you'll probably want the |
Thanks very much @krader1961, that is very helpful. For the potential benefit of others, here is exactly what I did. I created a function called do (stands for "disown", which might be a real fish command one day):
and I added this code to my config.fish: |
If there are any running jobs in the shell, we should not be closing without a warning that the jobs are lost into the greater process list hierarchy. I don't think it should matter if the jobs running are background or foreground, but tell me why I'm wrong.
The text was updated successfully, but these errors were encountered: