I have written a C++ code to program STB1132-25 BLE module by calling/executing BlueNRG-X_Flasher_Launcher.exe through the c standard function system(const char*). I have the same setup for ST-LINK_CLI.exe to program STM32 controllers. I am passing correct arguments to both programming tools. I can successfully flash both the BLE module and stm32 controllers. But when some error occurred in X_Flasher_Launcher.exe, I always get a return code 0 and my code interprets it as a successful operation. I am not facing the same problem with ST-LINK_CLI.exe. when some error occurs, it returns =>1 and my code interprets it as an error.
For example, if ST-LINK/V2 programmer is not connected or target is not connected then ST-LINK_CLI.exe fails and returns 1 but BlueNRG-X_Flasher_Launcher.exe also fails, and return 0. basically, irrespective of failure or success it always returns 0.
Could anyone suggest to me how should I resolve this issue?
I know system(const char*) is not the best way to call an external program. but I just want to have a solution that works and later I will implement Windows' solution to call external programs (for e.g. createProcess).
OS: Windows 10 programming software tool: BlueNRG-X_Flasher_Launcher.exe v4.1.0, ST-LINK_CLI.exe v3.1.0
Edit: I have specified the wrong return codes. I updated the post with correct values.