flockfile does not work with stdout (on

Dan Nelson dnelson at allantgroup.com
Tue Apr 5 20:40:50 PDT 2005


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 at allantgroup.com


More information about the freebsd-questions mailing list