J
James Colannino
Hey everyone. I'm writing a small application in Python that uses
os.fork() to create a separate process in which another application is
run in the background. The problem is that I need to know whether or
not that separate application managed to start and return from within
the parent appropriately. Here's, roughly, a pseudo example of what I
want to do (I know the code itself is not correct):
def function():
pid = os.fork()
if pid:
do parent stuff
else:
try:
execute the application
exeption:
somehow return -1 from within the parent process
#try to start another application in the background from within a forked
process
if (function() == -1):
fail
Is there a way that I can do this? I thought, only for a *VERY* brief
second, about cheating my way around this with a global variable, but
then I realized that this wouldn't work due to the fact that I will have
multiple forks doing the same thing at the same time. Thanks in advance
James
os.fork() to create a separate process in which another application is
run in the background. The problem is that I need to know whether or
not that separate application managed to start and return from within
the parent appropriately. Here's, roughly, a pseudo example of what I
want to do (I know the code itself is not correct):
def function():
pid = os.fork()
if pid:
do parent stuff
else:
try:
execute the application
exeption:
somehow return -1 from within the parent process
#try to start another application in the background from within a forked
process
if (function() == -1):
fail
Is there a way that I can do this? I thought, only for a *VERY* brief
second, about cheating my way around this with a global variable, but
then I realized that this wouldn't work due to the fact that I will have
multiple forks doing the same thing at the same time. Thanks in advance
James