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 p911takU009057 for ; Sat, 1 Oct 2011 03:55:36 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApgBAI9yhk7RVdK2mGdsb2JhbABBhGWjRggiAQEBAQEICQ0HFCWBUwEBAQQSAg8dATgBAwwBBQULDQICJgICIhIBBQEcBhMIGqF/CosJgyCEeYkpAgQGgSeBbIJ0MmEEk1yNEz2BSIJB X-IronPort-AV: E=Sophos;i="4.68,470,1312149600"; d="scan'208";a="122370900" Received: from mail-iy0-f182.google.com ([209.85.210.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 01 Oct 2011 03:55:32 +0200 Received: by iadk27 with SMTP id k27so4721719iad.27 for ; Fri, 30 Sep 2011 18:55:31 -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; bh=7G6ivUSsthvyAvHxTqLH66IKIywlWQThOTHufnosg4o=; b=ZM6L0mm+KoQi6I9/065kjrE9KNh9IJRkCKAooT/w/xjcaaItpC2uBe2opInKC4x8Ba EN35XWO1+i+uNjsRBY/ylYQ3RpZwOJ3G1ZMeQnntza7IDvdtJnM303Owz88Ps0J1onJY DgP2tVqtmozDueboLJ3/aRDXmcub+IrzASEM4= MIME-Version: 1.0 Received: by 10.42.130.193 with SMTP id w1mr3802913ics.176.1317434130611; Fri, 30 Sep 2011 18:55:30 -0700 (PDT) Sender: tcvena@gmail.com Received: by 10.42.227.138 with HTTP; Fri, 30 Sep 2011 18:55:30 -0700 (PDT) In-Reply-To: <20110930094501.GA24085@pps.jussieu.fr> References: <20110930094501.GA24085@pps.jussieu.fr> Date: Fri, 30 Sep 2011 21:55:30 -0400 X-Google-Sender-Auth: bV9Jjxus4Sbg4UvUlwTWRqX2d_c Message-ID: From: Taylor Venable To: Jerome Vouillon Cc: caml-list Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Problem with un-flushed output getting mangled 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. -- Taylor C. Venable http://metasyntax.net/