Changeset bb34771


Ignore:
Timestamp:
2010-03-14T16:35:55Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
caceb06
Parents:
286b28e
Message:

Close fd's 0,1,2 no matter what, not just if they're ttys. (Bug #476)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    r286b28e rbb34771  
    109109                chdir( "/" );
    110110               
    111                 /* Sometimes std* are already closed (for example when we're in a RESTARTed
    112                    BitlBee process. So let's only close TTY-fds. */
    113                 if( isatty( 0 ) ) close( 0 );
    114                 if( isatty( 1 ) ) close( 1 );
    115                 if( isatty( 2 ) ) close( 2 );
     111                i = close( 0 ) == 0;
     112                i += close( 1 ) == 0;
     113                i += close( 2 ) == 0;
     114                /* To avoid that something important ends up on one of those
     115                   fd's, open them for something bogus. Otherwise RESTART
     116                   may cause troubles. */
     117                while( i > 0 )
     118                {
     119                        open( "/dev/null", O_WRONLY );
     120                        i --;
     121                }
    116122        }
    117123#endif
Note: See TracChangeset for help on using the changeset viewer.