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.
14 #include <sys/types.h>
16 #include <sys/ioctl.h>
23 #endif /* USE_SYSCONF */
31 nbits = sysconf( _SC_OPEN_MAX );
32 #else /* USE_SYSCONF */
33 nbits = getdtablesize();
34 #endif /* USE_SYSCONF */
36 if ( debug == 0 || !(isatty( 1 )) ) {
37 for ( i = 0; i < 5; i++ ) {
52 for ( i = 3; i < nbits; i++ )
57 if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
58 if ( debug ) perror( "/dev/null" );
71 #else /* USE_SETSID */
72 if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
73 (void) ioctl( sd, TIOCNOTTY, NULL );
76 #endif /* USE_SETSID */
79 (void) signal( SIGPIPE, SIG_IGN );