[CRIU] [PATCH] zdtm: don't trigger BUG if futex returns EINTR

Andrei Vagin avagin at openvz.org
Fri Aug 19 17:18:51 PDT 2016


From: Andrei Vagin <avagin at virtuozzo.com>

It can hapen in tty tests, where we get SIGHUP.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/zdtm/lib/lock.h     | 4 ++--
 test/zdtm/static/tty00.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/test/zdtm/lib/lock.h b/test/zdtm/lib/lock.h
index 362de49..db9e96d 100644
--- a/test/zdtm/lib/lock.h
+++ b/test/zdtm/lib/lock.h
@@ -64,7 +64,7 @@ static inline void futex_add_and_wake(futex_t *f, uint32_t v)
 				break;				\
 			ret = sys_futex(&(__f)->raw, FUTEX_WAIT,\
 					tmp, NULL, NULL, 0);	\
-			if (ret < 0 && errno == EAGAIN)			\
+			if (ret < 0 && (errno == EAGAIN || errno == EINTR)) \
 				continue;			\
 			BUG_ON(ret < 0 && errno != EWOULDBLOCK);	\
 		}						\
@@ -119,7 +119,7 @@ static inline uint32_t futex_wait_while(futex_t *f, uint32_t v)
 {
 	while (f->raw == v) {
 		int ret = sys_futex(&f->raw, FUTEX_WAIT, v, NULL, NULL, 0);
-		if (ret < 0 && errno == EAGAIN)
+		if (ret < 0 && (errno == EAGAIN || errno == EINTR))
 			continue;
 		BUG_ON(ret < 0 && errno != EWOULDBLOCK);
 	}
diff --git a/test/zdtm/static/tty00.c b/test/zdtm/static/tty00.c
index 3408557..aab0d0f 100644
--- a/test/zdtm/static/tty00.c
+++ b/test/zdtm/static/tty00.c
@@ -97,8 +97,10 @@ int main(int argc, char ** argv)
 			fail("The child returned %d", WEXITSTATUS(status));
 			return 1;
 		}
-	} else
+	} else {
 		test_msg("The child has been killed by %d\n", WTERMSIG(status));
+		return 1;
+	}
 
 	pass();
 
-- 
2.7.4



More information about the CRIU mailing list