execution of instructions in a child process
Posted
by
ness kh
on Stack Overflow
See other posts from Stack Overflow
or by ness kh
Published on 2012-10-12T21:28:23Z
Indexed on
2012/10/12
21:36 UTC
Read the original article
Hit count: 280
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
© Stack Overflow or respective owner