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
Corrupt output of printf
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-01-23 (15:53)
From: Eric Cooper <ecc@c...>
Subject: Re: [Caml-list] (Not) corrupt output of printf
On Fri, Jan 23, 2009 at 02:20:41PM +0000, Dawid Toton wrote:
> Let's see the output as a sequence of bytes (there's no time).
> Assuming that the process exits normally and incompatible printing  
> functions are not mixed:
> is there a guarantee (in OCaml library) that the flush operation doesn't  
> affect the output?

The flush operation only relates to the time at which the write
occurs (i.e., flush may make it occur sooner than it would otherwise).
So if you're ignoring the time element (and error cases like writing
to a full disk or a broken pipe), it's unobservable.

But if the output is part of a larger interactive system -- prompting
a user for input, or engaging in a 2-way protocol with another process
-- then flushing can be essential for correct behavior.

Eric Cooper             e c c @ c m u . e d u