fish-shell icon indicating copy to clipboard operation
fish-shell copied to clipboard

Fish doesn't print "job stopped" message on ctrl+z

Open pvonmoradi opened this issue 4 years ago • 3 comments

Normally, ctrl+z sends the current job to background, after which, a message like [1]+ Stopped app_name should be printed on console.
This behaviur is inconsistent in fish shell. For example when I do so for vim, it behaves correctly (shows fish: Job 1, 'vim' has stopped) but when I do it for v which is an alias for vim, it doesn't print this message. The following screencast shows this:

https://user-images.githubusercontent.com/1058151/126742316-3ba195c9-0c16-4908-8c24-647332e43fba.mp4

The message fish: Job 1, “vim $argv” has stopped is not shown on hitting ctrl-z in v.

versions:
fish, version 3.3.1 Linux thinkpad 5.4.0-77-generic #86~18.04.1-Ubuntu

pvonmoradi avatar Jul 23 '21 05:07 pvonmoradi

Yes, functions don't print the job has stopped message, which I can reproduce in 3.0.2 and current git master (c35ffc58f).

zanchey avatar Jul 23 '21 13:07 zanchey

So this is actually more deep-rooted than it appears. Fish functions can't actually be actively backgrounded (try background `function foo; sleep 10; end; foo &), so what's happening is the wrapper function is actually started, vim suspends, then the wrapper function ends (without being stopped). At this point, the job is stopped (because there are stopped processes in the job and control has returned to the shell main loop), but fish never reports the status of processes stopped within functions, so the transition happens quietly.

You can see this in action by running something like function foo; vim; echo function continuing; end; and then hitting ^Z while in vim: the function doesn't get background, the status message is printed, then control returns to the shell.

mqudsi avatar Oct 24 '21 04:10 mqudsi

Should fish functions behave like processes? This is why I don't use fish functions and use fish scripts instead.

iacore avatar Nov 11 '25 10:11 iacore