M
Markus Franz
Hi.
My little Python script creates some child-processes depending on how much
command line options were given:
for myvalue in sys.argv[1:]:
pid = os.fork()
if pid == 0:
do_something() # placeholder for operations
break
Now I do some difficult things inside each child process (above: function
do_something). These operations may take a long time.
How can I make it sure that every child-process terminates after x senconds
(wether it has finished or not)?
I don't know how to force a child-process to kill itself after x seconds. I
also don't know how to force a main process (parent) to kill a child-process
after x seconds.
I searched for something like:
for myvalue in sys.argv[1:]:
pid = os.fork()
if pid == 0:
os.exit(timeout)
do_something() # placeholder for operations
break
But there was nothing like this... Do you have an answer to my question???
Thank you.
Best regards
Markus Franz
My little Python script creates some child-processes depending on how much
command line options were given:
for myvalue in sys.argv[1:]:
pid = os.fork()
if pid == 0:
do_something() # placeholder for operations
break
Now I do some difficult things inside each child process (above: function
do_something). These operations may take a long time.
How can I make it sure that every child-process terminates after x senconds
(wether it has finished or not)?
I don't know how to force a child-process to kill itself after x seconds. I
also don't know how to force a main process (parent) to kill a child-process
after x seconds.
I searched for something like:
for myvalue in sys.argv[1:]:
pid = os.fork()
if pid == 0:
os.exit(timeout)
do_something() # placeholder for operations
break
But there was nothing like this... Do you have an answer to my question???
Thank you.
Best regards
Markus Franz