Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Apr 2005 22:40:49 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: flockfile does not work with stdout (on
Message-ID:  <20050406034049.GI64927@dan.emsphone.com>
In-Reply-To: <20050406022116.GB99381%till@score.is.tsukuba.ac.jp>
References:  <20050406022116.GB99381%till@score.is.tsukuba.ac.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Apr 06), Till Plewe said:
> How can I control the output of processes (forked from a single
> process) all writing to the same file?
> f{un,}lockfile(file) seems to work unless file=stdout.

If they are still the same process image (i.e. no execs), you could
mmap some ANONYMOUS|SHARED memory and wait on a flag byte with
atomic_cmpset().  Actually, writing to stdout should be atomic for most
writes (I have never seen gcc output garbled when doing parallel makes
for example).


-- 
	Dan Nelson
	dnelson@allantgroup.com



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