STDOUT_FILENO is usually set to blocking mode, but as we rely on this,
it is safer to clear the nonblock flag explicitly.
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);
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)