flockfile does not work with stdout (on

Till Plewe till at score.is.tsukuba.ac.jp
Tue Apr 5 22:13:16 PDT 2005


On Tue, Apr 05, 2005 at 10:40:49PM -0500, Dan Nelson wrote:
> 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).
> 

The life span of each process is quite short (<0.001s) and the system load
is fairly high (~40)

Thanks, your suggestion works. In fact flockfile also works if I
use cons25 instead of {x,ml,...}term. So the culprit may be X.

- Till



More information about the freebsd-questions mailing list