I want my C++ processes to pass their return value to open a python script.
cpp example file
int main()
{
//do something
//process is going to finish and is gonna return, for simplicity, 0
//retval = 0, or whatever the return value is going to be
popen("mypython_script.py retval")
return 0;
}
mypython_script.py
if __name__ == "__main__":
cpp_retval = sys.argv[1]
print(cpp_retval)
I don't know if it's possible for the C++ file to send their return value as described, but this is just the general behaviour I want to achieve.
I also have control over the parent process of each C++ process: it's another python script which is in charge of opening C++ files and killing their process if needed, so if you have a solution that involves using the parent process to fetch the return value from "cpp example file", that's more than welcome
EDIT: I forgot to add that I cannot ask the parent python process to wait for the C++ program to return something. In no way I can have "waits" of any sort in my program.