jorgebucaran/hydro

"There are still jobs active" on exit

TeddyDD opened this issue · 8 comments

Sometimes when closing terminal with CTRL-D there is error message

There are still jobs active:

   PID  Command
2235785  fish --private --command "
        ! command git --no-optional-locks rev-parse 2>/dev/null && set $_hydro_git && exit

        set branch (
            command git symbolic-ref --short HEAD 2>/dev/null ||
            command git describe --tags --exact-match HEAD 2>/dev/null ||
            command git rev-parse --short HEAD 2>/dev/null |
                string replace --regex -- '(.+)' '@\$1'
        )

        test -z \"\$$_hydro_git\" && set --universal $_hydro_git \"\$branch \"

        ! command git diff-index --quiet HEAD 2>/dev/null ||
            count (command git ls-files --others --exclude-standard) >/dev/null &&
            set info \"$hydro_symbol_git_dirty\"

        for fetch in $hydro_fetch false
            command git rev-list --count --left-right @{upstream}...@ 2>/dev/null |
                read behind ahead

            switch \"\$behind \$ahead\"
                case \" \" \"0 0\"
                case \"0 *\"
                    set upstream \" $hydro_symbol_git_ahead\$ahead\"
                case \"* 0\"
                    set upstream \" $hydro_symbol_git_behind\$behind\"
                case \*
                    set upstream \" $hydro_symbol_git_ahead\$ahead $hydro_symbol_git_behind\$behind\"
            end

            set --universal $_hydro_git \"\$branch\$info\$upstream \"

            test \$fetch = true && command git fetch --no-tags 2>/dev/null
        end
    " &

A second attempt to exit will terminate them.
Use 'disown PID' to remove jobs from the list without terminating them.

Pressing CTRL-D again allows to close the terminal.

It's quite rare and I can't reproduce it on demand.

We could try using disown to forget about background jobs as suggested by the warning. I used to have it like that, but then some terminals (notably Terminal on macOS) won't quit when you close the tab, which I found more annoying.

Let me see what I can do. 👌

I don't see this message in either iTerm or Alacritty. I see it only when I try to exit macOS Terminal and Hydro is fetching the git status in the background. Best I can suggest is to disable the prompt when closing the terminal or setting $hydro_fetch back to false (false is the default).

tpict commented

I can reproduce this in Alacritty 0.7.2–try hitting enter, then ctrl-D immediately afterwards

Can you do disable the prompt on Alacritty like I did on macOS Terminal?

tpict commented

I'm not sure I understand–Alacritty closes the window by default if the shell exits, but in this case the shell doesn't exit because of the There are still jobs active error.

If you try Hydro on macOS Terminal with the prompt disabled as suggested above, you can see what I mean. If Alacritty can't do something like that, then just set $hydro_fetch back to false?

tpict commented

I see the same problem in the macOS terminal with the suggested setting and $hydro_fetch unchanged from default:

hydro.mov

This shows the enter, ctrl-D sequence showing the "still jobs active" warning, and then pressing ctrl-D again to close the shell (and terminal window).

Okay, I think this setting only makes sense when you close the terminal manually. For Ctrl+D there's nothing we can do as far as I can tell.

I'd love to fix this, but I have no idea how.