This is a discussion on Re: ntpd diff -- /var/run/ntpd.pid within the mailing.openbsd.tech forums, part of the OpenBSD category; --> On Wed, Aug 23, 2006 at 07:20:37PM +0000, Marcus Popp wrote: > Hi, re > i've created a diff ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Wed, Aug 23, 2006 at 07:20:37PM +0000, Marcus Popp wrote: > Hi, re > i've created a diff for the ntpd to store the pid in /var/run/ntpd.pid. > Maybe somebody is willing to integrate it? there is no need for ntpd.pid as generally they are only useful for newsyslog and ntpd clearly logs into plain syslog so no file to reopen. there is no other activities that ntpd is needed to do upon signal (except dying cu > Index: ntpd.8 > ================================================== ================= > RCS file: /cvs/src/usr.sbin/ntpd/ntpd.8,v > retrieving revision 1.14 > diff -u -r1.14 ntpd.8 > --- ntpd.8 21 Jun 2005 19:55:18 -0000 1.14 > +++ ntpd.8 23 Aug 2006 19:19:41 -0000 > @@ -105,6 +105,9 @@ > default > .Nm > configuration file > +.It Pa /var/run/ntpd.pid > +Contains the process ID of the > +.Nm > .El > .Sh SEE ALSO > .Xr date 1 , > Index: ntpd.c > ================================================== ================= > RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v > retrieving revision 1.41 > diff -u -r1.41 ntpd.c > --- ntpd.c 21 Feb 2006 23:47:00 -0000 1.41 > +++ ntpd.c 23 Aug 2006 19:19:41 -0000 > @@ -78,6 +78,7 @@ > main(int argc, char *argv[]) > { > struct ntpd_conf conf; > + static FILE *fin = NULL; > struct pollfd pfd[POLL_MAX]; > pid_t chld_pid = 0, pid; > const char *conffile; > @@ -91,6 +92,8 @@ > log_init(1); /* log to stderr until daemonized */ > res_init(); /* XXX */ > > + conf.pid_file = NTPD_PID_FILE; > + > while ((ch = getopt(argc, argv, "df:sS")) != -1) { > switch (ch) { > case 'd': > @@ -146,6 +149,17 @@ > signal(SIGCHLD, sighdlr); > signal(SIGHUP, sighdlr); > > + if (!conf.debug) { > + // Record our pid in /var/run/ntpd.pid > + fin = fopen(conf.pid_file, "w"); > + if (fin == NULL) { > + fprintf(stderr,"Couldn't create pid file \"%s\"", conf.pid_file); > + } else { > + fprintf(fin, "%ld\n", (long) getpid()); > + fclose(fin); > + } > + } > + > close(pipe_chld[1]); > > if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) > @@ -208,6 +222,7 @@ > fatal("wait"); > } while (pid != -1 || (pid == -1 && errno == EINTR)); > > + unlink(conf.pid_file); > msgbuf_clear(&ibuf->w); > free(ibuf); > log_info("Terminating"); > Index: ntpd.h > ================================================== ================= > RCS file: /cvs/src/usr.sbin/ntpd/ntpd.h,v > retrieving revision 1.61 > diff -u -r1.61 ntpd.h > --- ntpd.h 24 Sep 2005 00:32:03 -0000 1.61 > +++ ntpd.h 23 Aug 2006 19:19:41 -0000 > @@ -57,6 +57,7 @@ > #define SETTIME_MIN_OFFSET 180 /* min offset for settime at start */ > #define SETTIME_TIMEOUT 15 /* max seconds to wait with -s */ > #define LOG_NEGLIGEE 128 /* negligible drift to not log (ms) */ > +#define NTPD_PID_FILE "/var/run/ntpd.pid" > > enum client_state { > STATE_NONE, > @@ -130,6 +131,7 @@ > u_int8_t settime; > u_int8_t debug; > u_int32_t scale; > + char *pid_file; > }; > > struct buf { > -- paranoic mickey (my employers have changed but, the name has remained) |