5

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?

  • 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 Jan 22 '13 at 19:53
10

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.