From owner-freebsd-current Sat May 20 23:06:29 1995 Return-Path: current-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id XAA25155 for current-outgoing; Sat, 20 May 1995 23:06:29 -0700 Received: from leo.ibms.sinica.edu.tw ([140.109.40.249]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id XAA25149 for ; Sat, 20 May 1995 23:06:27 -0700 Received: (from taob@localhost) by leo.ibms.sinica.edu.tw (8.6.11/8.6.9) id OAA17063; Sun, 21 May 1995 14:06:23 +0800 Date: Sun, 21 May 1995 14:06:22 +0800 (CST) From: Brian Tao To: FREEBSD-CURRENT-L cc: Bill Fenner Subject: rwhod bugfix In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: current-owner@FreeBSD.org Precedence: bulk On Thu, 18 May 1995, Bill Fenner wrote: > > In fact, it prints an error to stderr... which daemon() just closed... =) Right. ;-) I've included two small patches below to fix this. The first one patches rwhod.c to print the error to stderr and exit (it just moves daemon() a little further down). The second fixes it to log the error via syslog() instead. I don't know which is better. I would prefer the syslog method, since rwhod is started in /etc/rc and stderr messages may be lost on the console. *** rwhod-orig.c Sun May 21 13:52:00 1995 --- rwhod-stderr.c Sun May 21 13:54:51 1995 *************** *** 127,140 **** fprintf(stderr, "rwhod: udp/who: unknown service\n"); exit(1); } - #ifndef DEBUG - daemon(1, 0); - #endif if (chdir(_PATH_RWHODIR) < 0) { (void)fprintf(stderr, "rwhod: %s: %s\n", _PATH_RWHODIR, strerror(errno)); exit(1); } (void) signal(SIGHUP, getboottime); openlog("rwhod", LOG_PID, LOG_DAEMON); /* --- 127,140 ---- fprintf(stderr, "rwhod: udp/who: unknown service\n"); exit(1); } if (chdir(_PATH_RWHODIR) < 0) { (void)fprintf(stderr, "rwhod: %s: %s\n", _PATH_RWHODIR, strerror(errno)); exit(1); } + #ifndef DEBUG + daemon(1, 0); + #endif (void) signal(SIGHUP, getboottime); openlog("rwhod", LOG_PID, LOG_DAEMON); /* *** rwhod-orig.c Sun May 21 13:52:00 1995 --- rwhod-syslog.c Sun May 21 13:55:49 1995 *************** *** 130,142 **** #ifndef DEBUG daemon(1, 0); #endif if (chdir(_PATH_RWHODIR) < 0) { ! (void)fprintf(stderr, "rwhod: %s: %s\n", _PATH_RWHODIR, strerror(errno)); exit(1); } - (void) signal(SIGHUP, getboottime); - openlog("rwhod", LOG_PID, LOG_DAEMON); /* * Establish host name as returned by system. */ --- 130,142 ---- #ifndef DEBUG daemon(1, 0); #endif + (void) signal(SIGHUP, getboottime); + openlog("rwhod", LOG_PID, LOG_DAEMON); if (chdir(_PATH_RWHODIR) < 0) { ! syslog(LOG_ERR, "%s: %s\n", _PATH_RWHODIR, strerror(errno)); exit(1); } /* * Establish host name as returned by system. */ -- Brian ("Though this be madness, yet there is method in't") Tao taob@gate.sinica.edu.tw <-- work ........ play --> taob@io.org