From: Jaroslav Kysela Date: Mon, 17 Feb 2003 18:07:24 +0000 (+0000) Subject: Don't clear resources in signal handler more than one time X-Git-Tag: v1.0.3~85 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=3ca23300be5b2eca85bac5f83956cd2560c7b536;p=alsa-utils.git Don't clear resources in signal handler more than one time --- 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); }