]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
afh/audioc: Explicitly mark STDOUT as blocking.
authorAndre Noll <maan@systemlinux.org>
Tue, 6 Dec 2011 17:17:57 +0000 (18:17 +0100)
committerAndre Noll <maan@systemlinux.org>
Wed, 4 Jan 2012 14:44:25 +0000 (15:44 +0100)
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
audioc.c

diff --git a/afh.c b/afh.c
index 66c4d1ca0f41a9c0b09ff2f70bc3ce566007bca8..4b4cc781144c5e0f68ac34ac8b98d3c5ad3f5912 100644 (file)
--- 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);
index e12d6e98fce4baa902d03e21c48aee4fba0237da..52c2bd3ae5b8d1c5f108c35b35447900362557f6 100644 (file)
--- 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)