]> git.alsa-project.org Git - alsa-utils.git/commitdiff
Don't clear resources in signal handler more than one time
authorJaroslav Kysela <perex@perex.cz>
Mon, 17 Feb 2003 18:07:24 +0000 (18:07 +0000)
committerJaroslav Kysela <perex@perex.cz>
Mon, 17 Feb 2003 18:07:24 +0000 (18:07 +0000)
aplay/aplay.c

index c06ec797b89f7867e16a7242260e34bbffa12160..0e1d6a1a165522ca3f0188921073596c0f4ed919 100644 (file)
@@ -26,6 +26,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <malloc.h>
 #include <unistd.h>
@@ -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);
 }