diff options
Diffstat (limited to 'discover/pb-discover.c')
-rw-r--r-- | discover/pb-discover.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/discover/pb-discover.c b/discover/pb-discover.c index d2ea7ae..024cb30 100644 --- a/discover/pb-discover.c +++ b/discover/pb-discover.c @@ -8,6 +8,13 @@ #include "waiter.h" #include "log.h" +static int running; + +void sigint_handler(int signum) +{ + running = 0; +} + int main(void) { struct device_handler *handler; @@ -17,6 +24,8 @@ int main(void) /* we look for closed sockets when we write, so ignore SIGPIPE */ signal(SIGPIPE, SIG_IGN); + signal(SIGINT, sigint_handler); + server = discover_server_init(); if (!server) return EXIT_FAILURE; @@ -31,11 +40,13 @@ int main(void) if (!udev) return EXIT_FAILURE; - for (;;) { + for (running = 1; running;) { if (waiter_poll()) - return EXIT_FAILURE; + break; } + device_handler_destroy(handler); + return EXIT_SUCCESS; } |