Date: Tue, 15 Jun 2021 22:40:22 -0400 From: Paul Procacci <pprocacci@gmail.com> To: Kurt Hackenberg <kh@panix.com> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: Is a successful call to write(2) atomic? Message-ID: <CAFbbPuhdNw4pQjKNyHnLpoNTkuxdr9=YcP%2BNQUTojz2eJnHfXg@mail.gmail.com> In-Reply-To: <303bd83e-0e32-85a2-58c0-59c90834a6f2@panix.com> References: <26204.1623801356@segfault.tristatelogic.com> <303bd83e-0e32-85a2-58c0-59c90834a6f2@panix.com>
next in thread | previous in thread | raw e-mail | index | archive | help
>> On reread, I see that Paul suggested that originally, many pipes, and >> that's what I was thinking. Paul's writing may not have been perfectly >> clear. This is what I was advocating for. Sorry if that wasn't clear. It might make sense to provide a visual representation using C pseudo code: while(children_needed){ int pipes[2]; pipe(pipes); switch(vfork()){ case -1: _exit(123); case 0: /** Remove/Move unnecessary fds - fcntl(2) for example - make one end of the pipe the child's stdout maybe? */ exec(); _exit(123); } /** Remove/Move unnecessary fds - fcntl(2) for example */ /** Store other end of pipe fd to poll later - can use an fdset for use with select(2) or kqueue(2) */ --children_needed; } The above, again just pseudo code, describes what I meant, which is essentially ... a Parent orchestrating the children .... reading their ends of the pipes for their childrens input ... and then later on (not shown in the pseudo code), doing something with that data. The above is probably a bit winded, but I felt the need to describe what I specifically meant, and there's no better way to do that with actual code, even if it's pseudo code. By the looks of it, I think we both meant the same exact thing. ;) ~Paul * Full Warning - The above code needs a lot of work like checking return values of syscalls and acting accordingly. Do not use it as is. It was only thrown together to provide a quick visual representation. On Tue, Jun 15, 2021 at 8:19 PM Kurt Hackenberg <kh@panix.com> wrote: > On 2021/06/15 19:55, Ronald F. Guilmette 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. > > On reread, I see that Paul suggested that originally, many pipes, and > that's what I was thinking. Paul's writing may not have been perfectly > clear. > > Let us know whether it works. > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to " > freebsd-questions-unsubscribe@freebsd.org" > -- __________________ :(){ :|:& };:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFbbPuhdNw4pQjKNyHnLpoNTkuxdr9=YcP%2BNQUTojz2eJnHfXg>