Date: Sun, 21 May 1995 14:06:22 +0800 (CST) From: Brian Tao <taob@gate.sinica.edu.tw> To: FREEBSD-CURRENT-L <freebsd-current@FreeBSD.org> Cc: Bill Fenner <fenner@parc.xerox.com> Subject: rwhod bugfix Message-ID: <Pine.BSI.3.91.950521135852.15569R-100000@leo> In-Reply-To: <Pine.BSI.3.91.950519012618.876F-100000@leo>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSI.3.91.950521135852.15569R-100000>
