aboutsummaryrefslogtreecommitdiff
path: root/networking/ntpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-08-27 02:15:01 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-08-27 02:15:01 +0200
commit74c992af5c6b8cfe6214e705bc04f8c2f9d8a304 (patch)
tree0a47255194456a017a4c1b34257851e75514fa51 /networking/ntpd.c
parent1cd0d8600524de01d643db32bc05f4d4d0c30436 (diff)
downloadbusybox-w32-74c992af5c6b8cfe6214e705bc04f8c2f9d8a304.tar.gz
busybox-w32-74c992af5c6b8cfe6214e705bc04f8c2f9d8a304.tar.bz2
busybox-w32-74c992af5c6b8cfe6214e705bc04f8c2f9d8a304.zip
ntpd: with -q, exit after 60 seconds even if time is not synced.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r--networking/ntpd.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index fb3ef2e3c..6707e9bdb 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -1920,9 +1920,28 @@ static NOINLINE void ntp_init(char **argv)
1920 if (opts & OPT_N) 1920 if (opts & OPT_N)
1921 setpriority(PRIO_PROCESS, 0, -15); 1921 setpriority(PRIO_PROCESS, 0, -15);
1922 1922
1923 bb_signals((1 << SIGTERM) | (1 << SIGINT), record_signo); 1923 /* If network is up, syncronization occurs in ~10 seconds.
1924 /* Removed SIGHUP here: */ 1924 * We give "ntpd -q" a full minute to finish, then we exit.
1925 bb_signals((1 << SIGPIPE) | (1 << SIGCHLD), SIG_IGN); 1925 *
1926 * I tested ntpd 4.2.6p1 and apparently it never exits
1927 * (will try forever), but it does not feel right.
1928 * The goal of -q is to act like ntpdate: set time
1929 * after a reasonably small period of polling, or fail.
1930 */
1931 if (opts & OPT_q)
1932 alarm(60);
1933
1934 bb_signals(0
1935 | (1 << SIGTERM)
1936 | (1 << SIGINT)
1937 | (1 << SIGALRM)
1938 , record_signo
1939 );
1940 bb_signals(0
1941 | (1 << SIGPIPE)
1942 | (1 << SIGCHLD)
1943 , SIG_IGN
1944 );
1926} 1945}
1927 1946
1928int ntpd_main(int argc UNUSED_PARAM, char **argv) MAIN_EXTERNALLY_VISIBLE; 1947int ntpd_main(int argc UNUSED_PARAM, char **argv) MAIN_EXTERNALLY_VISIBLE;