Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jun 2021 16:55:56 -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:  <26204.1623801356@segfault.tristatelogic.com>
In-Reply-To: <b6349909-7073-52d5-504e-acc88cbd3a21@panix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In message <b6349909-7073-52d5-504e-acc88cbd3a21@panix.com>, 
Kurt Hackenberg <kh@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 
>of them.

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,...

Yes.  Obviously.

>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.


Regards,
rfg



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26204.1623801356>