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

Re: [ID 20000326.003] Not OK: perl v5.6.0 +v5.6.0-RC3 on i386-AT386-gnu 0.2 (UNINSTALLED)

Thread Previous
From:
Mark Kettenis
Date:
March 31, 2000 02:35
Subject:
Re: [ID 20000326.003] Not OK: perl v5.6.0 +v5.6.0-RC3 on i386-AT386-gnu 0.2 (UNINSTALLED)
Message ID:
200003311034.MAA29533@landau.wins.uva.nl
   Date: Fri, 31 Mar 2000 11:17:40 +0200
   From: Dominic Dunlop <domo@computer.org>

   At 19:16 +0200 2000-03-29, Mark Kettenis wrote:
   >On the Hurd, pipes are implemented in the same way as in BSD 4.4.
   >They're bidirectional and implemented using sockets.  S_ISFIFO() will
   >probably return false on the ends, since it only checks for FIFO-ness
   >and not for the ends being sockets (S_ISSOCK() will return true).  So
   >there is indeed a problem with POSIX-compliance.

   On MachTen, the file type is zero for pipe ends -- they are not even 
   being marked as being sockets.  If they were, S_ISFIFO would succeed 
   because of the rather tacky contents of sys/stat.h:

     *      @(#)stat.h      8.6 (Berkeley) 3/8/94
   ...
   #define S_IFIFO  0010000                /* named pipe (fifo) */
   ...
   #define S_IFSOCK 0140000                /* socket */
   ...
   #define S_ISFIFO(m)     ((m & 0170000) == 0010000 || \
			     (m & 0170000) == 0140000)      /* fifo or socket */
   ...
   #ifndef _POSIX_SOURCE
   ...
   #define S_ISSOCK(m)     ((m & 0170000) == 0010000 || \
			     (m & 0170000) == 0140000)      /* fifo or socket */
   #endif

That's exactly what 4.4 BSD does.  The fact that fstat(2) doesn't
return the file type is actually documented as a bug in the man page.
This suggests that it is a long standing bug, and it is IMHO Perl's
job to kludge around it.

   The fact that MachTen appears to be trying to kludge around the 
   issue, yet still fails, leads me conclude that it's buggy.  I hope 
   the Hurd does better.  Can you tell me what octal filetype my test 
   program reports, and what sys/stat.h maps that number to?

Your test program would report 0140000 (S_IFSOCK) on the Hurd.  But
I'm going to change it to return 0010000 (S_ISFIFO).  So eventually
this will become a non-issue for the Hurd.

   >However, I disagree that this is something that Perl should not work
   >around.  There is a long history of pipes being implemented using
   >sockets in BSD, and they're bidirectional since at least BSD 4.4.  So
   >there will be quite a few systems out there that implement pipes that
   >way.  We'll probably fix the Hurd to follow POSIX (and Linux) a bit
   >more closely, but that might not happen to other systems.

   I wouldn't mind seeing a work-around on systems which, for historical 
   reasons, identify pipe-ends as sockets; but I'm reluctant to put in a 
   hack to accommodate systems which don't bother to identify pipe-ends 
   at all.  That said, the comment at line 459 in doio.c suggests that 
   MachTen's not alone in being slapdash:

	   IoTYPE(io) = 's'; /* some OS's return 0 on fstat()ed socket */
			    /* but some return 0 for streams too, sigh */

As I said, it seems to be a long-standing BSD bug.

   Do feel free to submit a patch: I'm fighting other stuff just now.

I'm not very familiar with the Perl code, so don't expect me to
provide a patch :-(.  Let's hope someone suffering from the same
problems will add a fix.

Anyway, thanks for pointing me in the right direction.  That's another
Hurd bug caught by porting Perl :-).

Mark

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About