develooper Front page | perl.perl5.porters | Postings from March 2000

MachTen 4.1.4: Unnamed pipes don't have a valid file type [ID20000315.008]

Dominic Dunlop
March 22, 2000 03:52
MachTen 4.1.4: Unnamed pipes don't have a valid file type [ID20000315.008]
Message ID:
[Tenon: this is for your information -- I don't have a current 
support contract.]

[Copied to Perl5 porters list and a couple of people with different 
unreconstructed BSD derivatives: please tell me how this runs on for 

This problem originally came to light in development versions of perl 
5.6.0: a lack of file type information confuses perl and makes it 
unable to tell the read/write mode of a pipe end.  The code in 
question follows line 447 of perl's doio.c, but I don't propose 
patching perl to get around the problem -- particularly so near the 
release of 5.6.0 -- as this is clearly an OS bug.  To see it, try 

#include <stdio.h>
#include <sys/stat.h>
main(int ac, char **av)
   struct stat st;
   int ps[2];
   int i;

   if (pipe(ps)) {
     perror("Can't make pipes");
   for (i = 0; i < 2; i++) {
     if (fstat(ps[i], &st)) {
       fprintf(stderr, "Can't stat pipe end %d: ", i);
     printf("%#07o: end #%d is %sa pipe\n",
            st.st_mode & 0170000, i,
            S_ISFIFO(st.st_mode) ? "" : "not ");

On MachTen, it says that neither end of the pipe is a pipe, because 
the file type field of the mode word is zero.  You can write a 
similar program which says the same about the ends of a UNIX domain 
socket pair (which is, according to BSD tradition, exactly the same 
thing as a pipe).  A program which diddles with a named pipe, on the 
other hand, gets told that it is indeed dealing with a pipe if it 

This is wrong.  BSD UNIX has traditionally been fuzzy on this issue, 
but recent UNIXes (including recent BSD derivatives) and the POSIX 
standard are clear about having a file type for pipes, assigning it 
to the information for the pipe ends when the pipe is opened, and 
having S_ISFIFO() return true for such things.

Dominic Dunlop Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About