I'm automating a test using crash package. Is there some thing like $?, which can be used to check if the previous command executed successfully or not inside a crash shell?

For example, when command:

crash> bt -a

Is executed, how do I know if it was successful or not? The only solution in my mind is greping through the results, but it's not reliable when the environment changes.

This is what i get when I try echo $?:

crash> bt asd
bt: invalid task or pid value: asd
crash> $?
crash: command not found: $?
crash> echo $?
crash> q

$? always appears to be 0.

I already asked this question on superuser a few days back, but no help from there. Any help would be appreciated.

  • I only know of crash as something that analyses a Linux dump (under Ubuntu). Where do you get the prompt from (installed package + command)? – Anthon Jun 12 '13 at 12:44
  • This might be of help. Assuming this is the JVM shell. – user13742 Jun 12 '13 at 13:58
  • @Anthon start crash using crash <crashDump> <kernel> it will drop you in crash> shell where you can run the crash commands to analyze the crash. – limovala Jun 13 '13 at 4:55
  • what I am talking about is this – limovala Jun 13 '13 at 4:56
  • @AbhishekLal sorry, we are talking about the same, but I would not call that a shell (neither does the crash documentation). – Anthon Jun 13 '13 at 5:22

Sorry -- I misunderstood the original question.

The answer is no, there is no way to tell whether a crash utility command has completed successfully. The functions that are called to perform a command are all void functions, e.g., the "bt" command is declared like so:

void cmd_bt(void) { ... }


As hinted by @Anthon, this is not a "normal" *nix shell like Bash or Dash, but rather an application-specific prompt (q is not a POSIX built-in utility for example). From a quick look through man crash it looks like there is no command to get the exit code of the last command.


As @l0b0 already clarified this is not a normal shell. Apart from that it does not seem to have have echo as a command you can type at your prompt. Compare:

crash -h bt


crash -h echo

you would probably get the same result 0 if you tried at the crash> prompt:

spam ?0
  • There is echo command crash> help echo gives some help for echo Print a constant string. Give string as argument. C escape sequences may be used in the argument..... – limovala Jun 13 '13 at 5:46

The crash utility's "bt" command gives you the stack backtrace of a given task's last entry into kernel mode, be it via syscall or exception. It has no concept of the status of a task that no longer exists, i.e., one that was previously executed by a bash shell.

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.