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 p93Apllc030914 for ; Mon, 3 Oct 2011 12:51:47 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvwAAP2SiU7RVdK2mGdsb2JhbABChBtKoxMIIgEBAQEBCAkNBxQlgVMBAQEEDAYCDx0BOAEDDAEFAwILDQICJgICIQESAQUBHAYTIqQZCosJgyCDeokrAgQGgSeEYYETBJNgih6Cdj2BSIJB X-IronPort-AV: E=Sophos;i="4.68,478,1312149600"; d="scan'208";a="122574158" Received: from mail-iy0-f182.google.com ([209.85.210.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 03 Oct 2011 12:51:41 +0200 Received: by iadk27 with SMTP id k27so9103358iad.27 for ; Mon, 03 Oct 2011 03:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=hO3AShIPCMqB3seaU47dB4IBSbBXBfsUNZi7epEoC1c=; b=aDnoVY2XqMPPWK8/9pa+occPLp6RuRTJ5OZ8zBA0G9I+Pu+qeuTBVUd0tLascXv3IQ fGiY4KV+WgQ5NXwC/9+ZRySZpApq3e7AeX1V6oRKj5kY8lKFEu3lRw+JCuP6HCGT8ruU 7/6c1yhKaCHYUJN/BPpP9IAqZCTTonbHW4nnI= MIME-Version: 1.0 Received: by 10.42.74.195 with SMTP id x3mr2802781icj.2.1317639100537; Mon, 03 Oct 2011 03:51:40 -0700 (PDT) Sender: tcvena@gmail.com Received: by 10.42.227.138 with HTTP; Mon, 3 Oct 2011 03:51:40 -0700 (PDT) In-Reply-To: <4E86BD0E.2050203@gmail.com> References: <20110930094501.GA24085@pps.jussieu.fr> <4E86BD0E.2050203@gmail.com> Date: Mon, 3 Oct 2011 06:51:40 -0400 X-Google-Sender-Auth: l4cLTpO7c19ah0HMIdXuc-g6Fvo Message-ID: From: Taylor Venable To: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= Cc: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p93Apllc030914 Subject: Re: [Caml-list] Problem with un-flushed output getting mangled 2011/10/1 Török Edwin : > 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? No, I'm not using threads. -- Taylor C. Venable http://metasyntax.net/