ntpd pidfile

Alfonso Ranieri alforan at tin.it
Tue Mar 19 17:44:48 UTC 2019


Is there any reason to create the pidfile for ntpd even if with the -n 
option?

It may happen that busybox ntpd is run just to set or test the time with 
a server, while another ntpd is running with its pid file.

I usually use this patch to avoid the creation of the pid file:

diff --git a/networking/ntpd.c b/networking/ntpd.c
index b2e77929e..434a01258 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2641,7 +2641,8 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
          */
         cnt = G.peer_cnt * (INITIAL_SAMPLES + 1);

-       write_pidfile_std_path_and_ext("ntpd");
+       if (G_listen_fd>=0)
+               write_pidfile_std_path_and_ext("ntpd");

         while (!bb_got_signal) {
                 llist_t *item;
@@ -2814,7 +2815,8 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
                 }
         } /* while (!bb_got_signal) */

-       remove_pidfile_std_path_and_ext("ntpd");
+       if (G_listen_fd>=0)
+               remove_pidfile_std_path_and_ext("ntpd");
         kill_myself_with_sig(bb_got_signal);
  }




More information about the busybox mailing list