X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=afh.c;h=8810a28b8dacc83731c40a57f014b2190a3b81ab;hp=66c4d1ca0f41a9c0b09ff2f70bc3ce566007bca8;hb=748d1368bc96dd7e1af879df1ea41b4d52842f7e;hpb=a24d175e6d093d6d9f6e583c3026e45924bad621 diff --git a/afh.c b/afh.c index 66c4d1ca..8810a28b 100644 --- a/afh.c +++ b/afh.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 Andre Noll + * Copyright (C) 2008-2012 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -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); @@ -148,7 +152,7 @@ static int cat_file(struct afh_info *afhi, int audio_format_id, if (!size) continue; PARA_INFO_LOG("writing chunk %lu\n", i); - ret = write_all(STDOUT_FILENO, buf, &size); + ret = write_all(STDOUT_FILENO, buf, size); if (ret < 0) return ret; }