Is a successful call to write(2) atomic?
Ronald F. Guilmette
rfg at tristatelogic.com
Tue Jun 15 23:56:00 UTC 2021
In message <b6349909-7073-52d5-504e-acc88cbd3a21 at panix.com>,
Kurt Hackenberg <kh at panix.com> wrote:
>But it works by just changing the messaging mechanism a little: Have
>many pipes, one for each sender, all sending to the single write
>process, which uses the system call select() to wait for activity on any
You're correct! That sounds like a nice solution.
>The write process still has to make sure it reads all of a message from
>a pipe before going on to another pipe,...
>Did you mentions lines -- each sender
>sends one line to be written, and each line must be atomic, but it's OK
>to write the many lines in any order?
In the context of what I'm doing, yes. The ordering of the lines within
the output file is of no special importance. It's only important that
each line remains as a single unit and that it does not get mashed up
with parts from any other line.
>If it's not lines,
>then do something similar -- have an end-of-message marker, or precede
>each message with its length in bytes...
Yes, and yes. No worries. Each separate line ends with \n, so the exact
extent of each separate line is totally unambiguous.
More information about the freebsd-questions