]> git.sesse.net Git - vlc/commitdiff
* src/libvlc.c: use dameon() instead of fork() when available. It does some more...
authorGildas Bazin <gbazin@videolan.org>
Sun, 26 Sep 2004 17:54:56 +0000 (17:54 +0000)
committerGildas Bazin <gbazin@videolan.org>
Sun, 26 Sep 2004 17:54:56 +0000 (17:54 +0000)
src/libvlc.c
src/libvlc.h
src/vlc.c

index 09a1838b65047d47b4d3e61b9b83a7fc55e299f0..111688587a983dd19eaef615f7d0a81bc68d9c98 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
- *          Gildas Bazin <gbazin@netcourrier.com>
+ *          Gildas Bazin <gbazin@videolan.org>
  *          Derk-Jan Hartman <hartman at videolan dot org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -352,7 +352,17 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
 #ifndef WIN32
     if( config_GetInt( p_vlc, "daemon" ) )
     {
-        pid_t i_pid = 0;
+#if HAVE_DAEMON
+        if( daemon( 0, 0) != 0 )
+        {
+            msg_Err( p_vlc, "Unable to fork vlc to daemon mode" );
+            b_exit = VLC_TRUE;
+        }
+
+        p_vlc->p_libvlc->b_daemon = VLC_TRUE;
+
+#else
+        pid_t i_pid;
 
         if( ( i_pid = fork() ) < 0 )
         {
@@ -369,12 +379,13 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
         {
             /* We are the child */
             msg_Dbg( p_vlc, "daemon spawned" );
-            close( 0 );
-            close( 1 );
-            close( 2 );
+            close( STDIN_FILENO );
+            close( STDOUT_FILENO );
+            close( STDERR_FILENO );
 
             p_vlc->p_libvlc->b_daemon = VLC_TRUE;
         }
+#endif
     }
 #endif
 
index adb18ce1aa42ff3532a2a25139f4475fb8075c27..e5a81fc584741dc93365f7706ee5aa42ee220a15 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
- *          Gildas Bazin <gbazin@netcourrier.com>
+ *          Gildas Bazin <gbazin@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index 260df196f0e293cd2210436d3af6f9b155c06bec..b4c1bda17b0f8afd003eaab5b0216f0f32d38ad0 100644 (file)
--- a/src/vlc.c
+++ b/src/vlc.c
@@ -6,7 +6,7 @@
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
- *          Gildas Bazin <gbazin@netcourrier.com>
+ *          Gildas Bazin <gbazin@videolan.org>
  *          Derk-Jan Hartman <hartman at videolan dot org>
  *          Lots of other people, see the libvlc AUTHORS file
  *
@@ -51,7 +51,6 @@ static void SigHandler  ( int i_signal );
 int main( int i_argc, char *ppsz_argv[] )
 {
     int i_ret;
-    int b_cli = VLC_FALSE ;
 
 #ifndef SYS_DARWIN
     /* This clutters OSX GUI error logs */
@@ -156,4 +155,3 @@ static void SigHandler( int i_signal )
     }
 }
 #endif
-