English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
OCaml IDE (OCaml and stdout/stderr)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-06-21 (00:34)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] OCaml IDE (OCaml and stdout/stderr)
From: "Nathaniel J. Gaylinn" <ngaylinn@cs.brown.edu>

> 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
If it is to be standalone, why not write it in ocaml?


Jacques Garrigue