[mod.computers.ridge] bug in named pipes/open

bogstad@HOPKINS-EECS-BRAVO.ARPA (Bill Bogstad) (11/11/86)

Description:

    There is a bug in the ROS 3.3u3 implementation of named pipes
(fifos).  According to the manual page for the open() system call, a
O_WRONLY (write-only) open of a fifo will delay returning until another
process opens the fifo for reading.  Under ROS, however, the open
returns immediately.

Repeat-by:

    Compile the following program on another System V machine.  (I used
a 3B20 running S5R2.)  Invoke it the first time with a single argument,
which will create the fifo "foobar" in the current directory.  Invoke it
a second time with no arguments.  The process will hang because no
process has the fifo open for reading.  Use your interrupt character to
break out of the program.  If you do the same thing under ROS 3.3u3 the
program returns immediately.

Fix:

    Unfortunately, I don't have any ROS sources so I can't suggest a
fix.  All you can do for now is try to work around it until Ridge
distributes a fix.

				Bill Bogstad
				bogstad@hopkins-eecs-bravo.arpa

---CUT HERE---

/* Nov. 1986 - William Bogstad - Demonstrate bug in fifos under ROS 3.3u3 */

#include <fcntl.h>
#include <string.h>
#include <stdio.h>

main (argc, argv)
int argc;
char *argv[];
{
    int in_pipe;
    char *in_fn = "foobar";

    if (argc == 2) {
	mknod (in_fn, 010666, 0);
	fprintf (stderr, "%s: made\n", in_fn);
    	exit (0);
    }

    if ((in_pipe = open (in_fn, O_WRONLY)) >= 0) {
    	perror(in_fn);
	fprintf (stderr, "they were waiting\n");
    } else {
    	perror (in_fn);
	fprintf (stderr, "they weren't waiting\n");
    }

    exit (0);
}