From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p917BKXJ016376 for ; Sat, 1 Oct 2011 09:11:20 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhkBAGy8hk7RVdY2kGdsb2JhbABBhGWVAo5DCCIBAQEBCQkNBxQEIYFTAQEBBBICDx0BGxwCAwwGBQsNAgIFFgsCAgkDAgECARERAQUBHBMGAgIeh1uZbwqLCUSCXIRsPYhuAgQGgSeBbIJ4gRMEh3GLcIUlgSuGRD2DcA X-IronPort-AV: E=Sophos;i="4.68,472,1312149600"; d="scan'208";a="122386698" Received: from mail-bw0-f54.google.com ([209.85.214.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 01 Oct 2011 09:11:15 +0200 Received: by bkbzs8 with SMTP id zs8so4325019bkb.27 for ; Sat, 01 Oct 2011 00:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=DQLYUegSI7rvPomfMXMZBc6ShvTWn+8FzVhDmcNw4II=; b=FjFLHH1nGlj+ZZJo80Mty0KXpE8zQaJQ6uoYx2PEutV0pM67fHXtX+DGIFdydFdewX YlzOJfl7vWniXwGLOEaf07nh/6cgnt0nyfvFS/AOk0kgjul3yMx4Buaufdg1UMtk1C1P sC3ugcZccw2qhd2BgOlxsLuMSSMprGQZiyw3A= Received: by 10.204.135.89 with SMTP id m25mr6786619bkt.365.1317453074744; Sat, 01 Oct 2011 00:11:14 -0700 (PDT) Received: from [192.168.1.101] ([79.114.59.7]) by mx.google.com with ESMTPS id t13sm1380760fae.0.2011.10.01.00.11.11 (version=SSLv3 cipher=OTHER); Sat, 01 Oct 2011 00:11:12 -0700 (PDT) Message-ID: <4E86BD0E.2050203@gmail.com> Date: Sat, 01 Oct 2011 10:11:10 +0300 From: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Icedove/3.1.13 MIME-Version: 1.0 To: caml-list@inria.fr References: <20110930094501.GA24085@pps.jussieu.fr> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Problem with un-flushed output getting mangled On 10/01/2011 04:55 AM, Taylor Venable wrote: > On Fri, Sep 30, 2011 at 05:45, Jerome Vouillon wrote: >> On Thu, Sep 29, 2011 at 08:00:47PM -0400, Taylor Venable wrote: >>> My trouble is this: if I fail to call flush on the output channels in >>> step #4, I get mangled output. By mangled I mean that in the middle of >>> one line, suddenly the data from another line appears. The other line >>> exists elsewhere in the output. Sometimes lines are simply duplicated. >> >> Are you using Unix.fork? When you fork, the buffers are duplicated and >> can thus end up being flushed several times. In particular, the 'exit' >> function from the Pervasives module flushes all open output channels. >> I don't have a good workaround. You can call 'flush_all' before >> forking, but any write error is silently ignored by this function. >> Or use 'Unix.execv "/bin/true" [||]' rather than 'exit' to terminate >> subprocesses. > > Nope, I'm not forking. I also tried putting an explicit exit at the > end of my program, but I already close_out my file before then so it > doesn't make a difference. Thanks for the ideas, though. > Do you use threads? --Edwin