]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/ngircd.c
Don't play games with FILE* stdin/out/err, only touch "real" descriptors.
[ngircd-alex.git] / src / ngircd / ngircd.c
index e39229a06d97e252c61515d74fce8c3e16abeb6f..84b329e3f2d6ac147069bdfa7f1b05ea5659a98f 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: ngircd.c,v 1.91 2005/02/10 12:49:04 alex Exp $";
+static char UNUSED id[] = "$Id: ngircd.c,v 1.93 2005/02/10 16:55:52 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -61,7 +61,7 @@ LOCAL VOID Show_Help PARAMS(( VOID ));
 LOCAL VOID Pidfile_Create PARAMS(( LONG ));
 LOCAL VOID Pidfile_Delete PARAMS(( VOID ));
 
-LOCAL VOID NGIRCd_FillVersion PARAMS(( VOID ));
+LOCAL VOID Fill_Version PARAMS(( VOID ));
 
 LOCAL VOID Setup_FDStreams PARAMS(( VOID ));
 
@@ -88,7 +88,7 @@ main( int argc, const char *argv[] )
        strlcpy( NGIRCd_ConfFile, SYSCONFDIR, sizeof( NGIRCd_ConfFile ));
        strlcat( NGIRCd_ConfFile, CONFIG_FILE, sizeof( NGIRCd_ConfFile ));
 
-       NGIRCd_FillVersion( );
+       Fill_Version( );
 
        /* Kommandozeile parsen */
        for( i = 1; i < argc; i++ )
@@ -391,7 +391,7 @@ main( int argc, const char *argv[] )
 
 
 LOCAL VOID
-NGIRCd_FillVersion( VOID )
+Fill_Version( VOID )
 {
        NGIRCd_VersionAddition[0] = '\0';
 
@@ -443,7 +443,7 @@ NGIRCd_FillVersion( VOID )
 #else
        snprintf( NGIRCd_Version, sizeof NGIRCd_Version, "%s %s-%s", PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_VersionAddition);
 #endif
-} /* NGIRCd_FillVersion */
+} /* Fill_Version */
 
 
 GLOBAL VOID
@@ -637,7 +637,7 @@ Pidfile_Create( LONG pid )
 LOCAL VOID
 Setup_FDStreams( VOID )
 {
-       int fd;
+       INT fd;
 
        /* Test if we can open /dev/null for reading and writing. If not
         * we are most probably chrooted already and the server has been
@@ -646,18 +646,13 @@ Setup_FDStreams( VOID )
        if ( fd < 0 ) return;
 
        /* Close "old" stdin/out/err descriptors */
-       fclose( stdin ); fclose( stdout ); fclose( stderr );
+       close( 0 ); close( 1 ); close( 2 );
 
        /* Create new stdin(0), stdout(1) and stderr(2) descriptors */
        dup2( fd, 0 ); dup2( fd, 1 ); dup2( fd, 2 );
 
        /* Close newly opened file descriptor if not stdin/out/err */
        if( fd > 2 ) close( fd );
-
-       /* Assign FILE handles for stdin/out/err */
-       stdin = fdopen( 0, "r" );
-       stdout = fdopen( 1, "w" );
-       stderr = fdopen( 2, "w" );
 } /* Setup_FDStreams */