From owner-freebsd-questions@freebsd.org Tue Jun 15 23:56:00 2021 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4DF25656969 for ; Tue, 15 Jun 2021 23:56:00 +0000 (UTC) (envelope-from rfg@tristatelogic.com) Received: from outgoing.tristatelogic.com (segfault.tristatelogic.com [69.62.255.118]) by mx1.freebsd.org (Postfix) with ESMTP id 4G4QFC3JX1z3rQN for ; Tue, 15 Jun 2021 23:55:58 +0000 (UTC) (envelope-from rfg@tristatelogic.com) Received: by segfault.tristatelogic.com (Postfix, from userid 1237) id E8A2C4E680; Tue, 15 Jun 2021 16:55:56 -0700 (PDT) From: "Ronald F. Guilmette" To: freebsd-questions@freebsd.org Subject: Re: Is a successful call to write(2) atomic? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26203.1623801356.1@segfault.tristatelogic.com> Date: Tue, 15 Jun 2021 16:55:56 -0700 Message-ID: <26204.1623801356@segfault.tristatelogic.com> X-Rspamd-Queue-Id: 4G4QFC3JX1z3rQN X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of rfg@tristatelogic.com designates 69.62.255.118 as permitted sender) smtp.mailfrom=rfg@tristatelogic.com X-Spamd-Result: default: False [-1.41 / 15.00]; ARC_NA(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[69.62.255.118:from]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[tristatelogic.com]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[69.62.255.118:from:127.0.2.255]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.11)[-0.107]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:14051, ipnet:69.62.128.0/17, country:US]; SUBJECT_ENDS_QUESTION(1.00)[]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jun 2021 23:56:00 -0000 In message , Kurt Hackenberg 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