summaryrefslogtreecommitdiff
path: root/libc/misc/syslog
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-13 05:47:19 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-12-13 05:47:19 +0100
commit6732cb1ae137d7af17eb911004ba904badba1b85 (patch)
tree6468ba5fd5642fbcd4e2b5bd5078fff96de07b63 /libc/misc/syslog
parent1eac4f3880f10a4a9702939b60d322b40db08972 (diff)
syslog: use send(MSG_NOSIGNAL) instead of write, thus no need to handle SIGPIPE
Size changes by this and previous change: text data bss dec hex filename 1151 13 2 1166 48e libc/misc/syslog/syslog.o 1093 10 2 1105 451 libc/misc/syslog/syslog.o 1047 10 2 1059 423 libc/misc/syslog/syslog.o Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libc/misc/syslog')
-rw-r--r--libc/misc/syslog/syslog.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c
index f66ba8faf..b10a55615 100644
--- a/libc/misc/syslog/syslog.c
+++ b/libc/misc/syslog/syslog.c
@@ -85,6 +85,10 @@
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+/* !glibc_compat: glibc uses argv[0] by default
+ * (default: if there was no openlog or if openlog passed NULL),
+ * not string "syslog"
+ */
static const char *LogTag = "syslog"; /* string to tag the entry with */
static int LogFile = -1; /* fd for log */
static smalluint connected; /* have done connect */
@@ -188,16 +192,11 @@ vsyslog(int pri, const char *fmt, va_list ap)
int fd, saved_errno;
int rc;
char tbuf[1024]; /* syslogd is unable to handle longer messages */
- struct sigaction action;
/* Just throw out this message if pri has bad bits. */
if ((pri & ~(LOG_PRIMASK|LOG_FACMASK)) != 0)
return;
- memset(&action, 0, sizeof(action));
- action.sa_handler = closelog_intern;
- sigaction(SIGPIPE, &action, &action);
-
saved_errno = errno;
__UCLIBC_MUTEX_LOCK(mylock);
@@ -268,7 +267,8 @@ vsyslog(int pri, const char *fmt, va_list ap)
*last_chr = '\0';
if (LogFile >= 0) {
do {
- rc = write(LogFile, p, last_chr + 1 - p);
+ /* can't just use write, it can result in SIGPIPE */
+ rc = send(LogFile, p, last_chr + 1 - p, MSG_NOSIGNAL);
if (rc < 0) {
/* I don't think looping forever on EAGAIN is a good idea.
* Imagine that syslogd is SIGSTOPed... */
@@ -302,7 +302,6 @@ vsyslog(int pri, const char *fmt, va_list ap)
getout:
__UCLIBC_MUTEX_UNLOCK(mylock);
- sigaction(SIGPIPE, &action, NULL);
}
libc_hidden_def(vsyslog)