When I execute a command using system(COMMAND)
function in C++
code running on Linux,
the return values of calls of system(COMMAND)
are not same from each other.
Do we have any ways to detect segmentation fault or abnormal termination by using return value of system(COMMAND)
function?
For example, when I got segmentation fault after executing a command by using system
function, I confirmed the return value of that function was 35584. However, I could not know what that return value means, and I am not sure all possible segmentation faults return 35584.
Is there a way to detect all possible values of return values when I encounter segmentation fault or abnormal termination?
man 3 system
refers to man 2 wait
for the meaning of return value. The latter page describes several macros usable with this value, notably WIFSIGNALED(status)
and WTERMSIG(status)
. That's what you can use to check for segmentation fault or termination on other signals.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With