-
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
$status incorrect when SIGSTOP is sent #2524
Comments
My bash (4.3.42) and zsh (5.1.1) give me 148, not 146. Also: What would you like to do? If you'd like to detect when something has been backgrounded, this isn't actually a proper way to do it, because any program can return 148 or 146 (in fact they can return anything from 0 to 255). So we should find a better way. |
Many status lines (including mine) have an error indicator by checking the status of the last command. I slightly modified mine in my bash/zsh scripts to ignore 146, because I background a lot and don't want it to be considered as an error. It works for my main system where I use this prompt, and that's good enough for me at the minute. The reason you get 148 and I get 146 is because SIGSTP/SIGSTOP numbers aren't portable (I'm running fish on Mac OS X). I don't think they can return anything from 0 to 255 in bash and zsh, though, as the ABS guide specifies that exit codes 128+n are reserved for signals (where n is the signal code), and zsh seems to follow suit there, so maybe fish should too. I haven't tried all other signals, but SIGKILL – whose code, 9, is – seems to give the correct result (137) in fish. I'm all for detecting that the process was backgrounded, as it does seem like a better approach if it's portable. However, I think it's probably a good idea to fix this too. |
That's a convention, not something that's technically enforced - compile and execute this C code, then check the return code: int main() {
return 255;
} My bash also gives 255.
Okay, so you'd like to not show it in the prompt. So... what should this look like? My first thought was to make a signal handler for SIGSTOP/SIGCONT that sets a "job_exited" variable or similar, and then add that to the prompt, but that doesn't work currently since fish doesn't seem to catch it (I know that it's possible on linux at least since it was part of one of the worst design decisions of upstart). I don't have any idea for a particularly beautiful interface - though I do like correct interfaces. |
Of course, but I'm talking about something of personal preference. I'd rather have to use the traditional method of finding out if the last command was successful for the odd program that breaks convention than see an error every time I stop vim to do something on the command line.
Doesn't Perhaps something to that effect could work: function my_sig_handler --on-background
set __last_process_stopped 1
end Or maybe even a new fish function that would kill 2 birds with one stone: function fish_background_message
...
end
function fish_foreground_message
...
end Would allow me to customise (or silence) the messages printed to the console on fg/bg, something that's been on my wishlist since I started playing around with fish a few weeks ago. |
Andy Earnshaw notifications@github.com writes:
Humm, I was under the impression that fish receives the signal. Guess
Yeah, that might be okay - or rather a special event "fish_background"
Yeah, but this wouldn't solve the original problem - we'd usually want
|
Seems like a sensible thing to do. |
The "job has stopped" message is now customizable via fish_job_summary, so I think this has been done for some time. |
I'm noticing a discrepancy when backgrounding in Fish shell. In fish, zsh and bash, do the following:
sleep 10000000
echo $?
for bash/zsh,echo $status
for fishIn zsh and bash, I get 146. In fish, I get 1, or 0 if I send
kill -stop
with the pid of the sleep process.The text was updated successfully, but these errors were encountered: