I need to implement something like this:
while True:
conn,addr = socket.accept()
restore()
p.kill()
#...
p = subprocess.Popen(...)
But I need that the restore()
function is called not only after every new connection, but also as soon as p dies.
I can "block" my program waiting for p death by doing p.wait()
, however I also want, at the same time, to block my program waiting for a new connection.
In other words, I need to block my program until one of these two conditions is true : "p dies" OR "new connection".
I know I can use select
to wait for two file descriptors, but I don't know how to do in this case.
Thanks