Don't clear resources in signal handler more than one time

This commit is contained in:
Jaroslav Kysela 2003-02-17 18:07:24 +00:00
parent cab2b63bef
commit 3ca23300be

View file

@ -26,6 +26,7 @@
* *
*/ */
#define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <malloc.h> #include <malloc.h>
#include <unistd.h> #include <unistd.h>
@ -268,13 +269,19 @@ static void version(void)
static void signal_handler(int sig) static void signal_handler(int sig)
{ {
if (!quiet_mode) if (!quiet_mode)
fprintf(stderr, "Aborted...\n"); fprintf(stderr, "Aborted by signal %s...\n", strsignal(sig));
if (stream == SND_PCM_STREAM_CAPTURE) if (stream == SND_PCM_STREAM_CAPTURE) {
fmt_rec_table[file_type].end(fd); fmt_rec_table[file_type].end(fd);
if (fd > 1) stream = -1;
}
if (fd > 1) {
close(fd); close(fd);
if (handle) fd = -1;
}
if (handle) {
snd_pcm_close(handle); snd_pcm_close(handle);
handle = NULL;
}
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }