]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: handle EINTR in read()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 29 Jul 2018 21:54:32 +0000 (23:54 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 15:06:46 +0000 (16:06 +0100)
We don't want to link log.{c,h} against utils.{c,h} for the sake of our static
builds init.lxc.static. This means lxc_write_nointr() will not be available. So
handle it EINTR.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/log.c

index 6f3d2ecf95cb8c50f3259e92d693decdf140ae23..03b88bf0f0bfa31c81a7a9cabff745e02f60bb09 100644 (file)
@@ -201,7 +201,8 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
 {
        char buffer[LXC_LOG_BUFFER_SIZE];
        char date_time[LXC_LOG_TIME_SIZE];
-       int n, ret;
+       int n;
+       ssize_t ret;
        int fd_to_use = -1;
 
 #ifndef NO_LXC_CONF
@@ -243,7 +244,12 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
 
        buffer[n] = '\n';
 
-       return write(fd_to_use, buffer, n + 1);
+again:
+       ret = write(fd_to_use, buffer, n + 1);
+       if (ret < 0 && errno == EINTR)
+               goto again;
+
+       return ret;
 }
 
 static struct lxc_log_appender log_appender_stderr = {