From: Damien Bobillot <damien.bobillot@m4x.org>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Named pipe problem: is this a bug?
Date: Mon, 1 Aug 2005 17:42:05 +0200 [thread overview]
Message-ID: <A5C6ED2E-62ED-443E-9F39-48F908D72B3F@m4x.org> (raw)
In-Reply-To: <F0577640-623F-4147-9745-300F4303D3E6@polytechnique.org>
[-- Attachment #1: Type: text/plain, Size: 1513 bytes --]
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
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2375 bytes --]
next prev parent reply other threads:[~2005-08-01 15:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-01 15:03 Alan Schmitt
2005-08-01 15:41 ` [Caml-list] " Virgile Prevosto
2005-08-01 15:42 ` Damien Bobillot [this message]
2005-08-01 15:55 ` Richard Jones
2005-08-02 7:59 ` Alan Schmitt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A5C6ED2E-62ED-443E-9F39-48F908D72B3F@m4x.org \
--to=damien.bobillot@m4x.org \
--cc=alan.schmitt@polytechnique.org \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox