mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-05 13:30:00 -05:00
pcm_file: fix pipe stall when pclose() is called too early
BugLink: https://github.com/alsa-project/alsa-lib/issues/14 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
4a480362eb
commit
193ed64fd9
1 changed files with 7 additions and 9 deletions
|
|
@ -71,6 +71,7 @@ typedef struct {
|
||||||
int trunc;
|
int trunc;
|
||||||
int perm;
|
int perm;
|
||||||
int fd;
|
int fd;
|
||||||
|
FILE *pipe;
|
||||||
char *ifname;
|
char *ifname;
|
||||||
int ifd;
|
int ifd;
|
||||||
int format;
|
int format;
|
||||||
|
|
@ -227,15 +228,10 @@ static int snd_pcm_file_open_output_file(snd_pcm_file_t *file)
|
||||||
file->final_fname);
|
file->final_fname);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
fd = dup(fileno(pipe));
|
fd = fileno(pipe);
|
||||||
err = -errno;
|
file->pipe = pipe;
|
||||||
pclose(pipe);
|
|
||||||
if (fd < 0) {
|
|
||||||
SYSERR("unable to dup pipe file handle for command %s",
|
|
||||||
file->final_fname);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
file->pipe = NULL;
|
||||||
if (file->trunc)
|
if (file->trunc)
|
||||||
fd = open(file->final_fname, O_WRONLY|O_CREAT|O_TRUNC,
|
fd = open(file->final_fname, O_WRONLY|O_CREAT|O_TRUNC,
|
||||||
file->perm);
|
file->perm);
|
||||||
|
|
@ -486,7 +482,9 @@ static int snd_pcm_file_close(snd_pcm_t *pcm)
|
||||||
if (file->wav_header.fmt)
|
if (file->wav_header.fmt)
|
||||||
fixup_wav_header(pcm);
|
fixup_wav_header(pcm);
|
||||||
free((void *)file->fname);
|
free((void *)file->fname);
|
||||||
if (file->fd >= 0) {
|
if (file->pipe) {
|
||||||
|
pclose(file->pipe);
|
||||||
|
} else if (file->fd >= 0) {
|
||||||
close(file->fd);
|
close(file->fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue