8

I just customized my .bashrc to include the exit status of the last command, so I get fancy prompts like

☑ larsmans@host:~$

and I no longer have to re-run commands to see their exit status because I ran some other command in between. This uses $? to determine the exit status. However, I noticed that when a command is backgrounded with Ctrl+Z, the shell also sets $?, so I keep seeing

[1]+  Stopped                 vim
☒ larsmans@host:~$ echo $?
148

Is this 148 a magic pseudo-exit status that I should check for?

1
  • I'm sure I'm not the only one guilty of just falling off the end of main() (and thus returning garbage as exit status). Others have turned out creative, returning anything from the number of items processed through the number of errors found to some perceived severity of the problems encountered. Several "original" Unix comands returned garbage as the exit status. vi(1) was a notorious example.
    – vonbrand
    Commented Jan 22, 2013 at 19:53

1 Answer 1

16

Found it just before hitting the "ask question" button. I looked at the ABS, which suggests this is exit code 128 + signal SIGTSTP (even though no process exited). I then found out I inspect check the exit status using

kill -l $?

which reports TSTP, or "stop typed at tty", for 148.

1
  • 7
    You don't have to apologise for answering your own question :-) Such things are encouraged on the Stack Exchange network.
    – Chris Down
    Commented Jan 22, 2013 at 16:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .