From a5f5ca5e8d937f6e0a01f71832f209603e389219 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 6 Dec 2011 18:17:57 +0100 Subject: [PATCH] afh/audioc: Explicitly mark STDOUT as blocking. STDOUT_FILENO is usually set to blocking mode, but as we rely on this, it is safer to clear the nonblock flag explicitly. --- afh.c | 4 ++++ audioc.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/afh.c b/afh.c index 66c4d1ca..4b4cc781 100644 --- a/afh.c +++ b/afh.c @@ -115,6 +115,10 @@ static int cat_file(struct afh_info *afhi, int audio_format_id, return -ERRNO_TO_PARA_ERROR(EINVAL); if (!afhi->chunks_total) return 1; + /* eliminate the possibility of short writes */ + ret = mark_fd_blocking(STDOUT_FILENO); + if (ret < 0) + return ret; if (first_chunk > 0 && !conf.no_header_given) { afh_get_header(afhi, audio_format_id, audio_file_data, audio_file_size, &header, &size); diff --git a/audioc.c b/audioc.c index e12d6e98..52c2bd3a 100644 --- a/audioc.c +++ b/audioc.c @@ -332,6 +332,9 @@ int main(int argc, char *argv[]) goto out; bufsize = conf.bufsize_arg; buf = para_malloc(bufsize); + ret = mark_fd_blocking(STDOUT_FILENO); + if (ret < 0) + goto out; do { size_t n = ret = recv_bin_buffer(fd, buf, bufsize); if (ret <= 0) -- 2.39.5