You want to check the return code from the C ++ program that you are using and exit if it indicates a failure. In the code below, / bin / false and / bin / true are programs that exit with errors and success codes, respectively. Replace them with your own program.
import os import sys status = os.system('/bin/true') if status != 0: # Failure occurred, exit. print 'true returned error' sys.exit(1) status = os.system('/bin/false') if status != 0: # Failure occurred, exit. print 'false returned error' sys.exit(1)
This assumes that the program you are running ends with zero success, other than zero on failure.
bstpierre
source share