hello, It seems like your OS (Linux here) is buffering all successive open-write-close sequences together and lumping all data together that can be read with a single open-read-close sequence. Here is a trace of the system calls for both the writer (first) and the reader (second).
# this is the writer trace # this sequence is repeated 4 times open("tst.fifo", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3 fstat64(3, {st_mode=S_IFIFO|0644, st_size=0, ...}) = 0 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 fstat64(3, {st_mode=S_IFIFO|0644, st_size=0, ...}) = 0 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, +-1, 0) = 0x40016000 write(3, "This is some silly,\n", 20) = 20 close(3) = 0 munmap(0x40016000, 4096) = 0
# this is the reader trace # notice how we got all 82 bytes at one shot write(1, "Opening pipe: ", 14) = 14 open("tst.fifo", O_RDONLY|O_LARGEFILE) = 3 fstat64(3, {st_mode=S_IFIFO|0644, st_size=0, ...}) = 0 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 write(1, "got pipe, reading:\n", 19) = 19 fstat64(3, {st_mode=S_IFIFO|0644, st_size=0, ...}) = 0 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, +-1, 0) = 0x40017000 read(3, "This is some silly,\nstuff to be "..., 4096) = 82 read(3, "", 4096) = 0 write(1, ": This is some silly,\n", 22) = 22 write(1, ": stuff to be sent\n", 19) = 19 write(1, ": to the pipe where hopefully\n", 30) = 30 write(1, ": it will be read.\n", 19) = 19 write(1, "Pipe done, closing: ", 20) = 20 close(3) = 0 munmap(0x40017000, 4096) = 0 write(1, "done.\n", 6) = 6 write(1, "Taking a long time... ", 22) = 22 time([1009160476]) = 1009160476
So, is this a bug? Dunno, since I'm not familiar with the POSIX specs on pipes.

Hope this helps.

Aziz,,,

Update:

From the pipe(4) man page:

Under Linux, opening a FIFO for read and write will suc? ceed both in blocking and non-blocking mode. POSIX leaves this behaviour undefined. This can be used to open a FIFO for writing while there are no readers available. A pro? cess that uses both ends of the connection in order to communicate with itself should be very careful to avoid deadlocks.
So, I guess under linux, the kernel choses to buffer the input when there are multiple succesive writes to a named pipe.

Hope this helps...


In reply to Re: Named pipes missing connections by abstracts
in thread Named pipes missing connections by bbfu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.