Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/rtadvd Print errors to stderr until we daemonize.



details:   https://anonhg.NetBSD.org/src/rev/119987176d1b
branches:  trunk
changeset: 1009994:119987176d1b
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 10 22:33:09 2020 +0000

description:
Print errors to stderr until we daemonize.
Fix typo.

diffstat:

 usr.sbin/rtadvd/rtadvd.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (69 lines):

diff -r 57d8bb5cf19a -r 119987176d1b usr.sbin/rtadvd/rtadvd.c
--- a/usr.sbin/rtadvd/rtadvd.c  Sun May 10 22:28:09 2020 +0000
+++ b/usr.sbin/rtadvd/rtadvd.c  Sun May 10 22:33:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtadvd.c,v 1.75 2020/04/21 12:23:13 wiz Exp $  */
+/*     $NetBSD: rtadvd.c,v 1.76 2020/05/10 22:33:09 christos Exp $     */
 /*     $KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $    */
 
 /*
@@ -54,6 +54,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <syslog.h>
+#include <signal.h>
 #include <stdarg.h>
 #ifdef __NetBSD__
 #include <util.h>
@@ -87,6 +88,7 @@
 int sock;
 int rtsock = -1;
 int Cflag = 0, dflag = 0, sflag = 0, Dflag;
+static int after_daemon = 0;
 
 static char **if_argv;
 static int if_argc;
@@ -214,16 +216,16 @@
        argc -= optind;
        argv += optind;
        if (argc == 0) {
-               fprintf(stderr, "Ysage: %s [-CDdfs] [-c conffile]"
+               fprintf(stderr, "Usage: %s [-CDdfs] [-c conffile]"
                    " [-p pidfile] interface ...\n", getprogname());
                return EXIT_FAILURE;
        }
 
        if ((pid = pidfile_lock(pidfilepath)) != 0) {
-               if (pid == -1)
+               if (pid == -1) {
                        logit(LOG_ERR, "pidfile_lock: %m");
                        /* Continue */
-               else {
+               } else {
                        logit(LOG_ERR, "Another instance of `%s' is running "
                            "(pid %d); exiting.", getprogname(), pid);
                        return EXIT_FAILURE;
@@ -265,6 +267,7 @@
 
        if (!fflag) {
                prog_daemon(1, 0);
+               after_daemon = 1;
                if (pidfile_lock(pidfilepath) != 0)
                        logit(LOG_ERR, " pidfile_lock: %m");
        }
@@ -1800,13 +1803,13 @@
        char *buf;
 
        va_start(ap, fmt);
-       if (!Dflag) {
+       if (!Dflag && after_daemon) {
                vsyslog(level, fmt, ap);
                va_end(ap);
                return;
        }
 
-       vfprintf(stderr, expandm(fmt, "\n", &buf), ap);
+       vwarnx(expandm(fmt, "\n", &buf), ap);
        free(buf);
        va_end(ap);
 }



Home | Main Index | Thread Index | Old Index