tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: partial failures in write(2) (and read(2))
On Feb 10, 2021, at 18:28, Thor Lancelot Simon <tls%panix.com@localhost> wrote:
>
> On Fri, Feb 05, 2021 at 08:10:06PM -0500, Mouse wrote:
>>> It is possible for write() calls to fail partway through, after
>>> already having written some data.
>>
>> It is. As you note later, it's also possible for read().
>>
>> The rightest thing to do, it seems to me, would be to return the error
>> indication along with how much was successfully written (or read). But
>> that, of course, requires a completely new API, which I gather is more
>> intrusive than you want to get into here.
>
> I think it could be done with a signal in combination with the existing
> API.
From the application’s perspective of calling write() in libc, when there is such an error the libc function could return a short response and set errno. That doesn’t work so much for the kernel’s system call. I suppose libc could set a default handler for the new signal, and do some extra work to set errno. Apps that need more control can override the signal hander.
jf
--
John Franklin
franklin%elfie.org@localhost
Home |
Main Index |
Thread Index |
Old Index