From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 4C3E3BBFA for ; Tue, 21 Jun 2005 02:34:10 +0200 (CEST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j5L0Y8RJ026252 for ; Tue, 21 Jun 2005 02:34:09 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j5L0Y4Aa023293; Tue, 21 Jun 2005 09:34:04 +0900 (JST) Date: Tue, 21 Jun 2005 09:34:43 +0900 (JST) Message-Id: <20050621.093443.08109440.garrigue@math.nagoya-u.ac.jp> To: ngaylinn@cs.brown.edu Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OCaml IDE (OCaml and stdout/stderr) From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 42B76080.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 ocaml:01 stdout:01 stderr:01 stdout:01 stderr:01 ocaml's:01 abstraction:01 buffering:01 ocaml's:01 buffered:01 buffering:01 guis:01 threads:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: From: "Nathaniel J. Gaylinn" > My program is having a hard time coping with how OCaml splits its output > between stdout and stderr. The order in which a line of output is received > from OCaml's stdout and a warning from its stderr seems to be completely > random and therefore my program's output is also random. I'm pretty sure > this has to do with how OCaml buffers stdout, but I'm not sure how to > change this. > > To make my program more portable, I'm writing it using the QT toolkit > which has a nice abstraction of inter-process communication in a class > called QProcess. This is what I'm using to communicate with OCaml. > > From your experience, do you think the buffering is taking place on > OCaml's end or on Qt's? Some research seems to suggest that how output is > buffered from a program can be controlled from within that program (since > there is direct access to the various output streams) but not from > outside. If that's true, then the buffering problem must be inside OCaml. > > Is there any nice way to force OCaml to flush its output buffers more > often? Is there any way to customize what data OCaml sends to stdout and > what it sends to stderr (this would be a nice feature to have!)? Do any > other ideas come to mind? I believe the problem is on QT's side. OCaml is flushing output just as much as necessary. Otherwise you would have incorrect output even in a terminal! The difficulty with GUIs is that they may add their own buffering. This is also the case with ocamlbrowser on windows for instance, because input has to be handled by separate threads. Then the main GUI thread ends up polling buffers filled by these threads. I remember I used to have problems with this solution, and solved it by having both the stdout and stderr reader threads write to the same buffer. But I don't know if you can get that level of access to QT internals... By the way, do you plan to integrate your IDE in kdevelop (or something else)? If it is to be standalone, why not write it in ocaml? Cheers, Jacques Garrigue