[lxc-devel] [lxc/master] tree-wide: handle EINTR in some read()/write()

brauner on Github lxc-bot at linuxcontainers.org
Fri Jun 1 17:56:31 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180601/ec888462/attachment.bin>
-------------- next part --------------
From 489f39bef7a3496704c8df9204c80411926269f4 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 1 Jun 2018 19:53:06 +0200
Subject: [PATCH] tree-wide: handle EINTR in some read()/write()

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/conf.c  | 10 +++++-----
 src/lxc/start.c |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index b67a90b6b..05d58081e 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2332,11 +2332,11 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount)
 		mount_entry = iterator->elem;
 		len = strlen(mount_entry);
 
-		ret = write(fd, mount_entry, len);
+		ret = lxc_write_nointr(fd, mount_entry, len);
 		if (ret != len)
 			goto on_error;
 
-		ret = write(fd, "\n", 1);
+		ret = lxc_write_nointr(fd, "\n", 1);
 		if (ret != 1)
 			goto on_error;
 	}
@@ -3951,7 +3951,7 @@ static int run_userns_fn(void *data)
 	/* Wait for parent to finish establishing a new mapping in the user
 	 * namespace we are executing in.
 	 */
-	if (read(d->p[0], &c, 1) != 1)
+	if (lxc_read_nointr(d->p[0], &c, 1) != 1)
 		return -1;
 
 	/* Close read end of the pipe. */
@@ -4224,7 +4224,7 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
 	}
 
 	/* Tell child to proceed. */
-	if (write(p[1], &c, 1) != 1) {
+	if (lxc_write_nointr(p[1], &c, 1) != 1) {
 		SYSERROR("Failed telling child process \"%d\" to proceed", pid);
 		goto on_error;
 	}
@@ -4401,7 +4401,7 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
 	}
 
 	/* Tell child to proceed. */
-	if (write(p[1], &c, 1) != 1) {
+	if (lxc_write_nointr(p[1], &c, 1) != 1) {
 		SYSERROR("Failed telling child process \"%d\" to proceed", pid);
 		goto on_error;
 	}
diff --git a/src/lxc/start.c b/src/lxc/start.c
index 882e37566..b222c847a 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -340,7 +340,7 @@ static int signal_handler(int fd, uint32_t events, void *data,
 	struct signalfd_siginfo siginfo;
 	struct lxc_handler *hdlr = data;
 
-	ret = read(fd, &siginfo, sizeof(siginfo));
+	ret = lxc_read_nointr(fd, &siginfo, sizeof(siginfo));
 	if (ret < 0) {
 		ERROR("Failed to read signal info from signal file descriptor %d", fd);
 		return LXC_MAINLOOP_ERROR;


More information about the lxc-devel mailing list