[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] main.c: exit on the first EPIPE error

From: Eric Blake
Subject: Re: [PATCH] main.c: exit on the first EPIPE error
Date: Fri, 20 Jan 2012 09:24:09 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

On 01/20/2012 07:40 AM, Paolo Bonzini wrote:
>> @@ -881,7 +882,7 @@ prline (char const *beg, char const *lim, int sep)
>>       fwrite (beg, 1, lim - beg, stdout);
>>     if (ferror (stdout))
>> -    error (0, errno, _("writing output"));
>> +    error ((errno == EPIPE) ? EXIT_FAILURE : 0, errno, _("writing
>> output"));
>>     lastout = lim;
> I think this should be EXIT_TROUBLE (aka exit status 2).  Jim/Paul, what
> do you think?

Alas, ferror() does not guarantee that errno is in a reliable state
compared to when the first write error was detected.  To properly check
for EPIPE, you'd have to check errno after every fputc(), fwrite(),
fprintf(), and so forth.

Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]