Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ztdm: inhfd: handle child hanging #2251

Draft
wants to merge 1 commit into
base: criu-dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions test/zdtm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

def alarm(*args):
print("==== ALARM ====")
raise InterruptedError("ALARM")


def traceit(f, e, a):
Expand Down Expand Up @@ -717,11 +718,9 @@ def start(self):
# regular files, so we loop.
data = b''
while not data:
# In python 2.7, peer_file.read() doesn't call the read
# system call if it's read file to the end once. The
# next seek allows to workaround this problem.
data = os.read(peer_file.fileno(), 16)
data = os.read(peer_file.fileno(), len(msg) + 16)
time.sleep(0.1)
peer_file.close()
except Exception as e:
print("Unable to read a peer file: %s" % e)
sys.exit(1)
Expand Down Expand Up @@ -752,7 +751,16 @@ def stop(self):
my_file.write(msg)
my_file.flush()
i += 1
pid, status = os.waitpid(self.__peer_pid, 0)
signal.alarm(10)
try:
pid, status = os.waitpid(self.__peer_pid, 0)
except InterruptedError:
fds = set(os.listdir("/proc/%s/fd" % self.__peer_pid))
self.kill()
pid, status = os.waitpid(self.__peer_pid, 0)
fds = self.__fds.difference(fds)
if fds:
print("before SIGKILL, child managed to close fds: " + str(fds))
with open(self.__name + ".out") as output:
print(output.read())
self.__peer_pid = 0
Expand Down
Loading