From owner-freebsd-questions@FreeBSD.ORG Wed Apr 6 05:13:16 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0210516A4CE for ; Wed, 6 Apr 2005 05:13:16 +0000 (GMT) Received: from plewe.is.tsukuba.ac.jp (plewe.cs.tsukuba.ac.jp [130.158.81.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4F8D543D41 for ; Wed, 6 Apr 2005 05:13:15 +0000 (GMT) (envelope-from till@plewe.is.tsukuba.ac.jp) Received: from plewe.is.tsukuba.ac.jp (localhost [127.0.0.1]) j365MVsi099742 for ; Wed, 6 Apr 2005 14:22:31 +0900 (JST) (envelope-from till@plewe.is.tsukuba.ac.jp) Received: (from till@localhost) by plewe.is.tsukuba.ac.jp (8.13.1/8.13.1/Submit) id j365MVTm099741 for freebsd-questions@freebsd.org; Wed, 6 Apr 2005 14:22:31 +0900 (JST) (envelope-from till) Date: Wed, 6 Apr 2005 14:22:31 +0900 From: Till Plewe To: freebsd-questions@freebsd.org Message-ID: <20050406052231.GA99716%till@score.is.tsukuba.ac.jp> Mail-Followup-To: freebsd-questions@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6i Subject: Re: flockfile does not work with stdout (on X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: till@score.is.tsukuba.ac.jp List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2005 05:13:16 -0000 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