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
Named pipe problem: is this a bug?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-08-01 (15:03)
From: Alan Schmitt <alan.schmitt@p...>
Subject: Named pipe problem: is this a bug?

I've stumbled upon a small bug, and I wonder if it's a OS X bug (I'm  
using X.4.2), or a caml bug. The problem is the following: I create a  
named pipe, then I open it. The open system call seems to block until  
there is data in the pipe.

Here is a small program illustrating this:

let _ =
   Unix.mkfifo "pipe_test" 0o640;
   print_endline "pipe created";
   flush stdout;
   let chin = open_in "pipe_test" in
     print_endline "pipe opened";
     flush stdout

Compile it using "ocamlc unix.cma bug.ml" (the bug occurs both in  
bytecode and native code). When a.out is run, one sees:
pipe created
and the program keeps running. If one then does a
echo foo >> pipe_test
then the "pipe opened" line is shown, and the program terminates.

Is this behaviour normal?


Alan Schmitt

The hacker: someone who figured this out and made something cool happen.