From 1eca354f629ef1d039c542ba96b9c6bcb62b7820 Mon Sep 17 00:00:00 2001 From: James Laird Date: Tue, 2 Apr 2013 21:27:14 +1100 Subject: [PATCH] shutdown cleanups now calls shairport_shutdown() when dying --- common.c | 2 +- common.h | 2 ++ shairport.c | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common.c b/common.c index cd006bc3..027610ec 100644 --- a/common.c +++ b/common.c @@ -45,7 +45,7 @@ void die(char *format, ...) { va_start(args, format); vfprintf(stderr, format, args); va_end(args); - exit(1); + shairport_shutdown(); } void warn(char *format, ...) { diff --git a/common.h b/common.h index b1b83979..d312a45c 100644 --- a/common.h +++ b/common.h @@ -29,4 +29,6 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode); extern shairport_cfg config; +void shairport_shutdown(void); + #endif // _COMMON_H diff --git a/shairport.c b/shairport.c index e95cabfe..b38808e5 100644 --- a/shairport.c +++ b/shairport.c @@ -33,7 +33,7 @@ #include "mdns.h" static int shutting_down = 0; -static void shutdown(void) { +void shairport_shutdown(void) { if (shutting_down) return; shutting_down = 1; @@ -47,7 +47,7 @@ static void shutdown(void) { static void sig_ignore(int foo, siginfo_t *bar, void *baz) { } static void sig_shutdown(int foo, siginfo_t *bar, void *baz) { - shutdown(); + shairport_shutdown(); } void usage(char *progname) { @@ -158,6 +158,6 @@ int main(int argc, char **argv) { rtsp_listen_loop(); // should not. - shutdown(); + shairport_shutdown(); return 1; }