aboutsummaryrefslogtreecommitdiffstats
path: root/test/run_ntp_server.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-08-29 10:12:06 +0200
committerMax Kellermann <max@duempel.org>2011-08-29 10:18:54 +0200
commita97ddc8cb955eb518f1864ccc2ee86b08010a347 (patch)
treed1034eced0e93e7655d0a2c37430c9853950a9f8 /test/run_ntp_server.c
parent59a5b000e03a17fd1708bb912a20ea198e5d1539 (diff)
downloadmpd-a97ddc8cb955eb518f1864ccc2ee86b08010a347.tar.gz
mpd-a97ddc8cb955eb518f1864ccc2ee86b08010a347.tar.xz
mpd-a97ddc8cb955eb518f1864ccc2ee86b08010a347.zip
test/run_ntp_server: quit on SIGINT or SIGTERM
Clean up the process before exiting.
Diffstat (limited to '')
-rw-r--r--test/run_ntp_server.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/run_ntp_server.c b/test/run_ntp_server.c
index bdee1fdcb..7268fa94c 100644
--- a/test/run_ntp_server.c
+++ b/test/run_ntp_server.c
@@ -19,6 +19,7 @@
#include "config.h"
#include "ntp_server.h"
+#include "signals.h"
#include <glib.h>
@@ -38,6 +39,14 @@
#include <arpa/inet.h>
#endif
+static bool quit = false;
+
+void
+on_quit(void)
+{
+ quit = true;
+}
+
static int bind_host(int sd, char *hostname, unsigned long ulAddr,
unsigned short *port)
{
@@ -113,6 +122,8 @@ open_udp_socket(char *hostname, unsigned short *port)
int
main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
{
+ signals_init();
+
struct ntp_server ntp;
ntp_server_init(&ntp);
@@ -123,7 +134,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
return EXIT_FAILURE;
}
- while (true) {
+ while (!quit) {
struct timeval tv = {
.tv_sec = 1,
.tv_usec = 0,