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 <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);
}