Date: Wed, 16 Jun 2021 16:18:22 -0700 From: "Ronald F. Guilmette" <rfg@tristatelogic.com> To: freebsd-questions@freebsd.org Subject: Re: Is a successful call to write(2) atomic? Message-ID: <31904.1623885502@segfault.tristatelogic.com> In-Reply-To: <af9666f4-f327-432e-5b10-100557aa9cf5@panix.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <af9666f4-f327-432e-5b10-100557aa9cf5@panix.com>, Kurt Hackenberg <kh@panix.com> wrote: >Since you only open the file once, you should seek to end of file before >each write, as somebody else pointed out. You should do that seek, and >the write, while holding the file lock. That is: > > lock file > seek to EOF > write > unlock file > >Does your code do that? Nope. I'll give it a try. Thanks! >The reason, of course, is that some other process could move end of file >out from under you while you do not hold the file lock. Sounds entirely plausible. Regards, rfg
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?31904.1623885502>