Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!ai-lab!opal!net From: net@opal.cs.tu-berlin.de (Oliver Laumann) Newsgroups: comp.unix.questions Subject: named pipes and O_RDWR Message-ID: <3374@kraftbus.cs.tu-berlin.de> Date: 17 May 91 09:40:39 GMT Sender: net@opal.cs.tu-berlin.de Organization: Technical University of Berlin, Germany Lines: 40 Is it allowed to open(2) a named pipe (FIFO) with O_RDWR? The X/Open Portability Guide explicitly says that in this case the result of the call to open() is undefined. On the other hand, P1003.1 and the manual pages on several UNIX versions do not explicitly forbid this. I have noticed that under SunOS, when a process opens several FIFOs with O_RDWR and then writes a single byte into each of these in turn, the 12th call to write() blocks. It blocks even if I set the respective file descriptors to non-blocking. This doesn't happen under Ultrix 4.0. I currently don't have access to other systems that support named pipes, so I can't check it there. Here is a small test program that demonstrates the `blocking write syndrome'. Before you run it, you have to mknod(8) 14 FIFOs named 0, 1, 2, etc. in the current directory. #include #define N 15 main () { int i, f[N]; char buf[10]; for (i = 0; i < N; i++) { sprintf (buf, "%d", i); if ((f[i] = open (buf, O_RDWR, 0)) == -1) { perror (buf); return; } } for (i = 0; i < N; i++) printf ("%d: %d\n", i, write (f[i], buf, 1)); } Regards, -- Oliver Laumann net@tub.cs.tu-berlin.de net@tub.UUCP ol@gnu.ai.mit.edu