Le 1 août 05 à 17:03, Alan Schmitt a écrit : > Hello, > > 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. Same thing on my computers (Mac OS X & Linux). In fact, a pipe is considered to be opened only if both ends exists (you've created the read end, "echo foo >> .." create the write end). http://www.annodex.net/cgi-bin/man/man2html?fifo+4 says : "The kernel maintains exactly one pipe object for each FIFO special file that is opened by at least one process. The FIFO must be opened on both ends (reading and writing) before data can be passed. Normally, opening the FIFO blocks until the other end is opened also." (it's no use to call flush after print_endline : printf_endline do the flush itself) -- Damien Bobillot