[CRIU] [PATCH] util: Don't swear on interrupted close syscall

Cyrill Gorcunov gorcunov at gmail.com
Tue May 2 14:16:53 PDT 2017


In case of EINTR here the descriptor will be
closed anyway.

http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html

Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
 criu/util.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/criu/util.c b/criu/util.c
index cb1e8fd..f5ed388 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -183,8 +183,12 @@ int close_safe(int *fd)
 		ret = close(*fd);
 		if (!ret)
 			*fd = -1;
-		else
-			pr_perror("Unable to close fd %d", *fd);
+		else {
+			if (errno != EINTR)
+				pr_perror("Unable to close fd %d", *fd);
+			else
+				ret = 0, *fd = -1;
+		}
 	}
 
 	return ret;
-- 
2.7.4



More information about the CRIU mailing list