Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.unix.programmer > #13643
| From | Rainer Weikusat <rweikusat@talktalk.net> |
|---|---|
| Newsgroups | comp.unix.programmer |
| Subject | Re: How to check for error with write(2) |
| Date | 2021-12-17 15:14 +0000 |
| Message-ID | <87mtkzz2k5.fsf@doppelsaurus.mobileactivedefense.com> (permalink) |
| References | <spfuo5$lb0$1@gioia.aioe.org> <slrnsrnfmu.1rfm.grahn+nntp@frailea.sa.invalid> <sph0n9$1vmq$1@gioia.aioe.org> |
Steve Keller <keller.steve@gmx.de> writes: > Jorgen Grahn <grahn+nntp@snipabacken.se> writes: >> The OpenBSD one is similar. Are you talking about other Unix-like >> systems, or are you saying the man page is wrong? Because it seems to >> say that in your scenario, the fatal write() will return -1 and set >> EFBIG. > > I should have written more clearly, that I was talking about a "short > write". I.e. the write() syscall doesn't return -1 and doesn't set > errno, but it could only write data partially. > > I wasn't saying the man page is wrong, only that an error can occur > without write() returning -1 to indicate the error. Repeating the > write() with the rest of the data to get the error, as Philip > suggested, was obviously too simple for me to get that idea :-) write generally needs to be called in a loop until either everything was written or an error ocurred, subject to whatever special properties the "output thing" the file descriptor refers to might have (eg, atomicity of PIPE_BUF writes to a pipe, or preservation of message boundaries by datagram sockets). But that's possibly not enough to detect errors reliably: I've encountered people who believed that a write call which cannot write anything due to the disk being full should return 0 and not -1 and an ENOSPC error. I don't know if implementations exist which actually work in this way.
Back to comp.unix.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to check for error with write(2) Steve Keller <keller.steve@gmx.de> - 2021-12-16 18:58 +0100
Re: How to check for error with write(2) scott@slp53.sl.home (Scott Lurndal) - 2021-12-16 18:26 +0000
Re: How to check for error with write(2) Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2021-12-20 13:52 +0000
Re: How to check for error with write(2) Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-12-16 18:49 +0000
Re: How to check for error with write(2) Rainer Weikusat <rweikusat@talktalk.net> - 2021-12-16 19:00 +0000
Re: How to check for error with write(2) Rainer Weikusat <rweikusat@talktalk.net> - 2021-12-16 19:06 +0000
Re: How to check for error with write(2) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2021-12-16 22:34 +0000
Re: How to check for error with write(2) Steve Keller <keller.steve@gmx.de> - 2021-12-17 04:38 +0100
Re: How to check for error with write(2) Rainer Weikusat <rweikusat@talktalk.net> - 2021-12-17 15:14 +0000
Re: How to check for error with write(2) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2021-12-18 10:25 +0000
Re: How to check for error with write(2) Philip Guenther <guenther@gmail.com> - 2021-12-16 15:04 -0800
Re: How to check for error with write(2) Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2021-12-16 20:10 -0700
Re: How to check for error with write(2) Steve Keller <keller.steve@gmx.de> - 2021-12-17 04:35 +0100
Re: How to check for error with write(2) Philip Guenther <guenther@gmail.com> - 2021-12-18 14:58 -0800
Re: How to check for error with write(2) scott@slp53.sl.home (Scott Lurndal) - 2021-12-19 16:07 +0000
csiph-web