From 3ca23300be5b2eca85bac5f83956cd2560c7b536 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 17 Feb 2003 18:07:24 +0000 Subject: [PATCH] Don't clear resources in signal handler more than one time --- aplay/aplay.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/aplay/aplay.c b/aplay/aplay.c index c06ec79..0e1d6a1 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -26,6 +26,7 @@ * */ +#define _GNU_SOURCE #include #include #include @@ -268,13 +269,19 @@ static void version(void) static void signal_handler(int sig) { if (!quiet_mode) - fprintf(stderr, "Aborted...\n"); - if (stream == SND_PCM_STREAM_CAPTURE) + fprintf(stderr, "Aborted by signal %s...\n", strsignal(sig)); + if (stream == SND_PCM_STREAM_CAPTURE) { fmt_rec_table[file_type].end(fd); - if (fd > 1) + stream = -1; + } + if (fd > 1) { close(fd); - if (handle) + fd = -1; + } + if (handle) { snd_pcm_close(handle); + handle = NULL; + } exit(EXIT_FAILURE); }