From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Sb561-0000Jp-Re for garchives@archives.gentoo.org; Sun, 03 Jun 2012 07:19:29 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DE371E0773; Sun, 3 Jun 2012 07:19:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 9B13DE071D for ; Sun, 3 Jun 2012 07:18:43 +0000 (UTC) Received: from [192.168.26.5] (ip98-164-193-252.oc.oc.cox.net [98.164.193.252]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id 0411F1B4008; Sun, 3 Jun 2012 07:18:42 +0000 (UTC) Message-ID: <4FCB0FD2.9030607@gentoo.org> Date: Sun, 03 Jun 2012 00:18:42 -0700 From: Zac Medico User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:12.0) Gecko/20120506 Thunderbird/12.0.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 To: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= CC: gentoo-dev@lists.gentoo.org, Brian Harring Subject: Re: [gentoo-dev] multiprocessing.eclass: doing parallel work in bash References: <201206011841.23302.vapier@gentoo.org> <201206021554.04552.vapier@gentoo.org> <20120602233132.24cc67ef@pomiocik.lan> <4FCA989E.3050307@gentoo.org> <20120602234726.GB9296@localhost> <4FCAB829.2000606@gentoo.org> <20120603091522.4c0ee5a6@pomiocik.lan> In-Reply-To: <20120603091522.4c0ee5a6@pomiocik.lan> X-Enigmail-Version: 1.5pre Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Archives-Salt: addfe694-3aa4-41cc-914c-9151fb3f9db6 X-Archives-Hash: 04c652b349df898415999ad22d574b2d On 06/03/2012 12:15 AM, Micha=C5=82 G=C3=B3rny wrote: > On Sat, 02 Jun 2012 18:04:41 -0700 > Zac Medico wrote: >=20 >> #!/usr/bin/env bash >> named_pipe=3D$(mktemp -d)/fifo >> >> ( >> # hold the pipe open in read mode, so >> # the writer doesn't block >> sleep 3 >> ) < "$named_pipe" & >=20 > I don't understand this part. This keeps the pipe open for reading > which obviously causes it to lose data. If you open it, you need to > read all that is there and then close. The point is, there's always a small window of time between when a reader reads its last byte, and when it finally closes the file descriptor. During this window, there's a race where a writer can come along and write something without blocking, and have that write be destroyed when the previous reader closes the fd. > And writers are supposed to be blocked. They are forked and just write > when done, so there's no problem with keeping them alive for a short > while. Yeah, but you need locking if you want to prevent the race that I've described above. --=20 Thanks, Zac