in reply to Named pipes missing connections
# 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
So, is this a bug? Dunno, since I'm not familiar with the POSIX specs on pipes.# 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
Hope this helps.
Aziz,,,
Update:
From the pipe(4) man page:
So, I guess under linux, the kernel choses to buffer the input when there are multiple succesive writes to a named pipe.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.
Hope this helps...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(bbfu) (in the OS) Re2: Named pipes missing connections
by bbfu (Curate) on Dec 24, 2001 at 05:21 UTC | |
by premchai21 (Curate) on Dec 24, 2001 at 08:45 UTC |