mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:05:42 +01:00
Don't clear resources in signal handler more than one time
This commit is contained in:
parent
cab2b63bef
commit
3ca23300be
1 changed files with 11 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue