log: handle EINTR in read()

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: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent a5bc6cb0
...@@ -290,7 +290,8 @@ static int log_append_logfile(const struct lxc_log_appender *appender, ...@@ -290,7 +290,8 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
{ {
char buffer[LXC_LOG_BUFFER_SIZE]; char buffer[LXC_LOG_BUFFER_SIZE];
char date_time[LXC_LOG_TIME_SIZE]; char date_time[LXC_LOG_TIME_SIZE];
int n, ret; int n;
ssize_t ret;
int fd_to_use = -1; int fd_to_use = -1;
const char *log_container_name = log_vmname; const char *log_container_name = log_vmname;
...@@ -340,7 +341,12 @@ static int log_append_logfile(const struct lxc_log_appender *appender, ...@@ -340,7 +341,12 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
buffer[n] = '\n'; 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_syslog = { static struct lxc_log_appender log_appender_syslog = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment