I am writing a python script which compiles and runs a C/C++ code. I want to capture runtime errors. Eg: Nzecv, Segmentation fault, Fragmentation Error etc
I am using following command to execute the compiled file:
process = Popen( exec_path , stdin=PIPE, stdout=PIPE, stderr=PIPE, shell= False)
(output, error) = process.communicate(testCase)
I have tried few programs with runtime errors, but the errors arent reflected in stderr. After some research i found that stderr reads from return value of program. And in C and mostly all other programs, main returns custom ("return 0;") value not the error signal.
Is it possible to catch runtime error signal? How should i go about implementing it?
EDIT: Can runtime error signal be captured by Terminal? HOW? If yes, ill run the corresponding shell script through python.