]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/detach.c
Fix Winsock-related warning and/or bugs.
[openldap] / libraries / liblutil / detach.c
index 5d27febf9c525e1a114bd54f16d3d0174eb90a60..c4f2aa4478eb6db60d4ec83cb3c0b0b6fa85aa41 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990, 1994 Regents of the University of Michigan.
  * All rights reserved.
 
 #include <stdio.h>
 
+#include <ac/stdlib.h>
 #include <ac/signal.h>
+#include <ac/socket.h>
 #include <ac/unistd.h>
 
 #include <sys/stat.h>
 #include <fcntl.h>
+
+#ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
+#endif
 
 #include "lutil.h"
 
@@ -59,7 +67,7 @@ lutil_detach( int debug, int do_close )
                                break;
 
                        default:
-                               _exit( 0 );
+                               _exit( EXIT_SUCCESS );
                        }
                        break;
                }
@@ -72,7 +80,7 @@ lutil_detach( int debug, int do_close )
 
                if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
                        perror( "/dev/null" );
-                       exit( 1 );
+                       exit( EXIT_FAILURE );
                }
                for ( i = 0;  i < 3;  i++ )
                        if ( sd != i && isatty( i ) )
@@ -82,13 +90,15 @@ lutil_detach( int debug, int do_close )
 
 #ifdef HAVE_SETSID
                (void) setsid();
-#else /* HAVE_SETSID */
+#elif TIOCNOTTY
                if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
                        (void) ioctl( sd, TIOCNOTTY, NULL );
                        (void) close( sd );
                }
-#endif /* HAVE_SETSID */
+#endif
        } 
 
+#ifdef SIGPIPE
        (void) SIGNAL( SIGPIPE, SIG_IGN );
+#endif
 }