[git commit] ntpd: do not create pid file if not backgrounded

Denys Vlasenko vda.linux at googlemail.com
Wed Mar 27 12:47:38 UTC 2019


commit: https://git.busybox.net/busybox/commit/?id=da996c5d2ace026506eb82d3b04ac48bb7aca3fb
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
ntp_init                                             995    1021     +26
ntpd_main                                           1267    1257     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 26/-10)             Total: 16 bytes

Reported by Alfonso Ranieri <alforan at tin.it>

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 networking/ntpd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/networking/ntpd.c b/networking/ntpd.c
index b2e77929e..027cfe783 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2585,6 +2585,10 @@ static NOINLINE void ntp_init(char **argv)
 		/* -l but no peers: "stratum 1 server" mode */
 		G.stratum = 1;
 	}
+
+	if (!(opts & OPT_n)) /* only if backgrounded: */
+		write_pidfile_std_path_and_ext("ntpd");
+
 	/* If network is up, syncronization occurs in ~10 seconds.
 	 * We give "ntpd -q" 10 seconds to get first reply,
 	 * then another 50 seconds to finish syncing.
@@ -2641,8 +2645,6 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
 	 */
 	cnt = G.peer_cnt * (INITIAL_SAMPLES + 1);
 
-	write_pidfile_std_path_and_ext("ntpd");
-
 	while (!bb_got_signal) {
 		llist_t *item;
 		unsigned i, j;


More information about the busybox-cvs mailing list