From: Radek Polak Date: Sat, 31 Mar 2012 07:50:16 +0000 (+0200) Subject: Exit the app in sighandler X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=704e4142ecf57bc3e38a91cfb68b23f8c62c7979;p=gta04-gsm-voice-routing.git Exit the app in sighandler --- 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; }