c - How to create a program that reads the last commands exit status? -


In Linux C, how can you read the exit status from the last programs

For example:

  true; $ Echo?  

Will show 0 for success. But I want to replace it with a C program:

  true; ./echo_exit_status  

How / where the final exit code is $? Is C program available?

The exit command is not accessible for the last command executed later In the program (absent horrifying hacking - associated with parent shell with debugger or somatoscope).

You can write a shell function or a helper that exports this value to the environment - but no solution is possible for which the shell's involvement is not required.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -