terminal warning with background process
Closed this issue · 6 comments
ble version: 0.4.0-devel4+9270b52
bash version: 3.2.57(1)-release (arm64-apple-darwin23)
I initially installed oh my bash and installed ble later. I used the quick installation method (source ~/.local/share/blesh/ble.sh). After installation, although I was able to use both ble and oh my bash without issues, it seems that the terminal is always running an additional process -bash
which slows down my machine. Once I remove source ~/.local/share/blesh/ble.sh
from ~/.bashrc
the issue is gone but of course I can't use ble anymore. Any idea how to fix this?
A couple things to note: I moved the source line for ble to above the oh my bash source line and the issue still occurs. The oh my bash version is the master branch on August 24th, 2024.
Thank you for the report, but the situation seems unclear in various aspects. More information is needed.
it seems that the terminal is always running an additional process
-bash
Is that really a process run by the terminal? You use Bash 3.2, so there should be also a process started by ble.sh
. In Bash 3.2, ble.sh
needs to set up an additional process to receive the C-d key, which is normally impossible to bind in Bash 3.2. My guess is that you misinterpreted the process started by ble.sh
as if it is run by the terminal, but if you have a reason to consider the remaining process is run by the terminal, could you describe it?
(Hereafter, I assume that the mentioned process is the one run by ble.sh
but not one run by the terminal.)
which slows down my machine.
If that process is the one started by ble.sh
, that process usually shouldn't be the one that slows down the user's machine. In general, ble.sh
in the main process requires more resources in Bash 3 because Bash 3 lacks a necessary feature to detect the next user input, so ble.sh
needs to perform the full rendering for every keystroke.
Why did you consider that the additional process slows down your machine? If you have any information or thoughts, could you describe it?
Once I remove
source ~/.local/share/blesh/ble.sh
from~/.bashrc
the issue is gone
The issue title says Oh My Bash compatibility issue, but If the process you mentioned is the one started by ble.sh
, the issue should be unrelated to Oh My Bash.
Also, I do not see the background to consider it being a compatibility issue with Oh My Bash (OMB) just from the provided descriptions. Have you checked that Oh My Bash is related (e.g. by confirming ble.sh without OMB doesn't cause the problem)? We can say it is a compatibility issue only when "ble.sh + OMB" causes the issue while neither "ble.sh without OMB" nor "OMB without ble.sh" causes the issue. If you have some observation or reason that you think this is a compatibility issue, could you provide the descriptions about them?
[Image]
How did you get this image? The situation where you get this message is unclear.
This message typically happens when the user closes the tab while a shell is running, but that kills the shell in an abnormal way and therefore should be avoided usually. In general, one should explicitly tell the shell to close the session by running the command exit
or pressing C-d on an empty command line.
Or does this message happen even after you exit the main shell by running exit
or pressing C-d (and you close the tab after that)?
@akinomyoga thank you for replying to my issue. Yes, I think you're right that the process is started by ble.sh instead of the terminal. And it is possible that this is unrelated to Oh My Bash. The image I sent occurs for every shell that I try to close with ble.sh enabled. I usually close down terminals with shortcut key command + w or just clicking the close button on the top right of the terminal. I tried to open a new terminal and immediately close it, but it would show me the image I sent that a process is still running in the shell.
Thank you for the clarification. The situations that I initially wasn't sure of became now clear.
I usually close down terminals with shortcut key command + w or just clicking the close button on the top right of the terminal.
What is your terminal?
I'm not sure how your terminal tries to terminate the currently running main shell process, but as far as the main shell process is properly terminated, that additional process started by ble.sh should also exit automatically. I guess your terminal checks the process tree even before trying to terminate the current main shell process. If this is the case, your terminal will display the message even when any shell setting uses a background process (which will be properly terminated on the main shell's exit). I don't think this is the issue specific to ble.sh, but this issue would happen with any shell settings with a background process (such as romkatv/gitstatus
). It is an impractical restriction that the terminal does not allow any background processes. Maybe there would be some workarounds provided by the terminal, but I don't know what terminal you use.
While testing ble.sh in Bash 3.2, I found serious regressions of ble.sh
triggered in Bash 3.2, where the error message appears on every command execution. I'm not sure whether you haven't noticed it or you just didn't actually run any command with ble.sh or you actually don't use Bash 3.2, but I fixed it in the latest push (commit 4984570). As far as you use Bash 3.2, I need to ask you to update ble.sh to the latest version by the following command (where /path/to/ble.sh
shall replaced with the actual path to the script file ble.sh
):
$ bash /path/to/ble.sh --update
After I mentioned romkatv/gitstatus
above, I thought there might be similar discussions there, so I searched. Then, I found one:
The error message in the above thread is exactly the same as yours, and the environment ("darwin" implying macOS) is also the same. There doesn't seem to be any solution for the terminal application side. I have to say that your terminal is too nice or too conservative to notify a possibility of an unintended tab closing, but it's merely a possibility. In the case of the additional process started by ble.sh, it is just safe to close the terminal because that process should immediately exit when the main shell process terminates. You can just ignore the message.
If you don't want to see the message, there are several options:
- As also instructed in #97@
romkatv/powerlevel10k
, you should actually stop the habit of closing the terminal's tab by the shortcut or the close button. It will forcibly terminate the shell in an unexpected way, so the shell will lose a chance to block its termination by itself. It can also lose a chance to perform the additional processing on the exit such as showing some messages. You should use the close button only when something is broken so that you lose the control of the shell. - You may try to find the terminal's option to disable the message.
- Another option is just to install the latest version of Bash by
brew
or something and switch to it by setting it to the default shell of the current user. Bash >= 4 doesn't have a problem with the binding of C-d, soble.sh
does not start the additional background process you observe. However, it should be noted that this doesn't solve the root problem; the same problem will happen again when you set up another shell setting that uses a background process.
which slows down my machine.
The performance issue you reported in the initial post should be a separate issue than the additional process started by ble.sh.
However, this is also related to the ble.sh
's implementation in Bash 3.2. As I mentioned in my first reply, Bash 3.2 lacks many features that can be used to efficiently implement ble.sh's processing. Also from this reason, I generally recomment the users to switch to the latest version of Bash.
So, for your personal use, I think you can switch to the latest version of Bash to escape from both issues.
Thank you. My end goal was to be able to close the terminal using the shortcut close or just the terminal UI but looks like what won't happen.
I've updated my bash to the latest version 5.2.32 as well as ble.sh, but the terminal still shows the warning.Once I switched my user to use the latest bash it no longer warns about the background process!- I've attempted to set the terminal to ignore the
-bash
background process shown in the image but that timeouts the terminal and made it unusable.
But yes I will try to close shells from now on cleanly instead.
Thank you for helping me understand the issue @akinomyoga and I will be closing the issue if there are no further comments