2 * Copyright (c) 1990, 1994 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
19 #include <sys/ioctl.h>
22 #include <ac/unistd.h>
29 #if defined( HAVE_SYSCONF )
30 nbits = sysconf( _SC_OPEN_MAX );
31 #elif defined( HAVE_GETDTABLESIZE )
32 nbits = getdtablesize();
38 if (nbits > FD_SETSIZE) {
41 #endif /* FD_SETSIZE*/
43 if ( debug == 0 || !(isatty( 1 )) ) {
44 for ( i = 0; i < 5; i++ ) {
59 for ( i = 3; i < nbits; i++ )
64 if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
65 if ( debug ) perror( "/dev/null" );
78 #else /* HAVE_SETSID */
79 if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
80 (void) ioctl( sd, TIOCNOTTY, NULL );
83 #endif /* HAVE_SETSID */
86 (void) signal( SIGPIPE, SIG_IGN );