execution of instructions in a child process
- by ness kh
I want to exit from a child process when the execution of os.system(comm) will be executed.
My code is:
pid = os.fork()
if pid == 0:
#instruction
else:
comm = "python file.py"
os.system(comm)
os.exit(error)
Now, my file file.py contains a loop, and I can get out from it only if a condition is satisfied. But, even when the condition is not satisfied, the program exits from the loop and displays the message error.
Also it doesn't execute the rest of instructions in file.py.
file.py is :
while 1:
if(condition):
break
# rest of instructions