From c1b2d194e91f05f08026a66ba677bbdefc338dda Mon Sep 17 00:00:00 2001 From: Pavel Tikhomirov Date: Tue, 1 Jun 2021 10:56:58 +0300 Subject: [PATCH] mem/pidfd: fix poll retry error checking One should never rely on errno if libc syscall is successful. We can either see an errno set from some previous failed syscall or even errno set by a this successful libc syscall. So lets check ret first. Fixes: 1ccdaf47 ("criu: add pidfd based pid reuse detection for RPC clients") Signed-off-by: Pavel Tikhomirov --- criu/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/criu/mem.c b/criu/mem.c index 4fa2b72ed..8809f5b1a 100644 --- a/criu/mem.c +++ b/criu/mem.c @@ -246,7 +246,7 @@ static int check_pidfd_entry_state(struct pidfd_entry *entry) while (1) { ret = poll(&pollfd, 1, 0); - if (errno == EINTR && restart_cnt < MAX_RESTARTS) { + if (ret == -1 && errno == EINTR && restart_cnt < MAX_RESTARTS) { restart_cnt++; continue; /* restart polling */ }