Subject: kern/2428: socketpair() fails if fd0 open
To: None <gnats-bugs@NetBSD.ORG>
From: None <>
List: netbsd-bugs
Date: 05/17/1996 19:31:30
>Number:         2428
>Category:       kern
>Synopsis:       socketpair() fails if fd0 open
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 17 15:05:01 1996
>Originator:     David Brownlee
	Monochrome (
>Release:        1.1B
System: NetBSD 1.1B NetBSD/sparc 1.1B Tue Apr 2 1996 and on more recent 1.1B NetBSD/i386

	If fd 0 is open socketpair() fails. Bizarre, and also pretty
	inconvenient if your application wants to use it!


#include <sys/types.h>  
#include <sys/socket.h>
    int sv[2];

    if( socketpair(AF_UNIX,SOCK_STREAM,0,sv) )
	perror("First call failed");
    puts("Now close fd 0");
    if( socketpair(AF_UNIX,SOCK_STREAM,0,sv) )
	perror("Second call failed");

	Fix unknown - I've kludged around it by dup()ing fd0 somewhere else,
	closing it, calling socketpair() then dup()ing ite back... uck...