Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/syslogd save/restore errno as necessary (printf() e...



details:   https://anonhg.NetBSD.org/src/rev/c9f40ac36763
branches:  trunk
changeset: 473568:c9f40ac36763
user:      lukem <lukem%NetBSD.org@localhost>
date:      Mon Jun 07 15:34:07 1999 +0000

description:
save/restore errno as necessary (printf() et al might have modified it...)

diffstat:

 usr.sbin/syslogd/syslogd.c |  10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diffs (48 lines):

diff -r ae96c017b84f -r c9f40ac36763 usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c        Mon Jun 07 15:25:19 1999 +0000
+++ b/usr.sbin/syslogd/syslogd.c        Mon Jun 07 15:34:07 1999 +0000
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)syslogd.c  8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.27 1999/06/06 01:55:58 thorpej Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.28 1999/06/07 15:34:07 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -305,9 +305,12 @@
                if (funix[j] < 0 || bind(funix[j],
                    (struct sockaddr *)&sunx, SUN_LEN(&sunx)) < 0 ||
                    chmod(*pp, 0666) < 0) {
+                       int serrno = errno;
                        (void)snprintf(line, sizeof line,
                            "cannot create %s", *pp);
+                       errno = serrno;
                        logerror(line);
+                       errno = serrno;
                        dprintf("cannot create %s (%d)\n", *pp, errno);
                        die(0);
                }
@@ -417,9 +420,11 @@
                                printline(LocalHostName, line);
                        } else if (i < 0 && errno != EINTR) {
                                char buf[MAXPATHLEN];
+                               int serrno = errno;
 
                                (void)snprintf(buf, sizeof buf,
                                    "recvfrom unix %s", *pp);
+                               errno = serrno;
                                logerror(buf);
                        }
                }
@@ -491,7 +496,10 @@
 
        fp = fopen(file, "r");
        if (fp == NULL) {
+               int serrno = errno;
+
                dprintf("can't open %s (%d)\n", file, errno);
+               errno = serrno;
                logerror("could not open socket file list");
                die(0);
        }



Home | Main Index | Thread Index | Old Index