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
Pipes and Standard Output / Input on Windows
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-05-29 (14:36)
From: Sylvain Le Gall <sylvain@l...>
Subject: Re: Pipes and Standard Output / Input on Windows
On 29-05-2008, John Whitington <john@coherentgraphics.co.uk> wrote:
> Hullo.
> I'm compiling OCaml command-line software with the MSVC toolchain on  
> Windows. Users have noticed two problems:
> (b) Chaining invocations of the tool together using pipes on Windows  
> often fails. The second process in the chain gets an End_Of_File after  
> only a few hundred bytes of data. I've confirmed the data is all being  
> output by the first process, and the first process is exiting cleanly.  
> All the open_in and open_out calls are using the _bin variant. The  
> data being sent down the pipe is a PDF file (which contains binary  
> sections).
> Neither of these problems occur on Linux / Mac builds - is there  
> something about windows pipes I should know?

Yep, on windows GetStdHandle doesn't always return the same kind of
handle depending on the context:
- if the output/input is console, it is console handle (i.e. need to be
  manipulated through console function)
- if the output/input is a pipe, it is a pipe handle (i.e. need to be
  manipulated through pipe function)

And since we are in the good old world of windows, the return type is an
HANDLE whatever it is ;-)

I think your issue is related to this difference. It can be fixed, but
you need a little bit of knowledge about windows pipe/standard handle.

Sylvain Le Gall