Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-dev
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: Michał Górny <mgorny@g.o>
From: Zac Medico <zmedico@g.o>
Subject: Re: multiprocessing.eclass: doing parallel work in bash
Date: Sun, 03 Jun 2012 00:18:42 -0700
On 06/03/2012 12:15 AM, Michał Górny wrote:
> On Sat, 02 Jun 2012 18:04:41 -0700
> Zac Medico <zmedico@g.o> wrote:
> 
>> #!/usr/bin/env bash
>> named_pipe=$(mktemp -d)/fifo
>>
>> (
>> 	# hold the pipe open in read mode, so
>> 	# the writer doesn't block
>> 	sleep 3
>> ) < "$named_pipe" &
> 
> 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.
-- 
Thanks,
Zac


References:
multiprocessing.eclass: doing parallel work in bash
-- Mike Frysinger
Re: multiprocessing.eclass: doing parallel work in bash
-- Mike Frysinger
Re: multiprocessing.eclass: doing parallel work in bash
-- Michał Górny
Re: multiprocessing.eclass: doing parallel work in bash
-- Zac Medico
Re: multiprocessing.eclass: doing parallel work in bash
-- Michał Górny
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: multiprocessing.eclass: doing parallel work in bash
Next by thread:
Re: multiprocessing.eclass: doing parallel work in bash
Previous by date:
Re: multiprocessing.eclass: doing parallel work in bash
Next by date:
Git braindump: 1 of N: merging & git signing


Updated Jun 29, 2012

Summary: Archive of the gentoo-dev mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.