From 704e4142ecf57bc3e38a91cfb68b23f8c62c7979 Mon Sep 17 00:00:00 2001 From: Radek Polak Date: Sat, 31 Mar 2012 09:50:16 +0200 Subject: [PATCH] Exit the app in sighandler --- gsm-voice-routing.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gsm-voice-routing.c b/gsm-voice-routing.c index f6a6dae..d308f69 100644 --- a/gsm-voice-routing.c +++ b/gsm-voice-routing.c @@ -530,12 +530,15 @@ struct route_stream r1 = { .period_buffer = 0 }; -static void close_route_streams() +static void cleanup() { close_route_stream(&p0); close_route_stream(&p1); close_route_stream(&r0); close_route_stream(&r1); + + set_aux_leds(0, 0); + fclose(logfile); } static void sighandler(int signum) @@ -545,7 +548,8 @@ static void sighandler(int signum) } terminating = 1; fprintf(logfile, "received signal %d\n", signum); - close_route_streams(); + cleanup(); + exit(0); } int main() @@ -642,9 +646,6 @@ int main() #endif fprintf(logfile, "ending up\n"); - close_route_streams(); - set_aux_leds(0, 0); - fclose(logfile); - + cleanup(); return 0; } -- 2.39.5