logger: ensure program writes everything to syslog file descriptor

It is fair assumption messages an user is asking to be wrote will be
attempted to be wrote as hard as possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2014-06-22 22:59:57 +01:00
parent 6443dd43da
commit 633493beaf
1 changed files with 3 additions and 2 deletions

View File

@ -51,6 +51,7 @@
#include <netdb.h>
#include <getopt.h>
#include "all-io.h"
#include "c.h"
#include "closestream.h"
#include "nls.h"
@ -281,8 +282,8 @@ static void mysyslog(int fd, int logflags, int pri, char *tag, char *msg)
snprintf(buf, sizeof(buf), "<%d>%.15s %.200s%s: %.400s",
pri, tp, cp, pid, msg);
if (write(fd, buf, strlen(buf)+1) < 0)
return; /* error */
if (write_all(fd, buf, strlen(buf)+1) < 0)
warn(_("write failed"));
}
}