]> git.sesse.net Git - vlc/commitdiff
* first stab at vlc daemon mode (-d, --daemon )
authorDerk-Jan Hartman <hartman@videolan.org>
Wed, 30 Jun 2004 16:26:48 +0000 (16:26 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Wed, 30 Jun 2004 16:26:48 +0000 (16:26 +0000)
include/main.h
src/libvlc.c
src/libvlc.h

index e57e4d7728f02556bbf740dbcab188c61722b805..3154e852ebf3191cb9355353a6574a52a89abf3a 100644 (file)
@@ -3,7 +3,7 @@
  * Declaration and extern access to global program object.
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
- * $Id: main.h,v 1.57 2004/01/25 18:17:08 zorglub Exp $
+ * $Id$
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
@@ -55,6 +55,9 @@ struct libvlc_t
     module_bank_t *        p_module_bank;
 
     /* Arch-specific variables */
+#if !defined( WIN32 )
+    vlc_bool_t             b_daemon;
+#endif 
 #if defined( SYS_BEOS )
     vlc_object_t *         p_appthread;
     char *                 psz_vlcpath;
index 07a5e5f706f3a70b4efdf06a6727760388a31741..653e0e88e5eb13373a304865b939e5b33bd0122b 100644 (file)
@@ -570,6 +570,34 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
     {
         p_vlc->pf_memset = memset;
     }
+    
+    /* Check for daemon mode */
+    if( config_GetInt( p_vlc, "daemon" ) )
+    {
+        pid_t i_pid = 0;
+        if( ( i_pid = fork() ) < 0 )
+        {
+            msg_Err( p_vlc, "Unable to fork vlc to daemon mode" );
+            exit(1);
+        }
+        else if( i_pid )
+        {
+            /* This is the parent, exit right now */
+            msg_Dbg( p_vlc, "closing parent process" );
+            exit(0);
+        }
+       else
+       {
+            /* we are the child */
+           msg_Dbg( p_vlc, "we are the child !!!" );
+            close( 0 );
+            close( 1 );
+            close( 2 );
+
+            p_vlc->p_libvlc->b_daemon = VLC_TRUE;
+           //VLC_AddIntf( 0, "logger,none", VLC_FALSE, VLC_FALSE );
+       }
+    }
 
     /*
      * Initialize hotkey handling
index d20d32d6a2b7161483f399675c41af425d49dd19..5c5281928e7945456ccde30ff41d801cccf68e57 100644 (file)
@@ -593,6 +593,10 @@ static char *ppsz_align_descriptions[] =
     "This option allows you to use a plugins cache which will greatly " \
     "improve the start time of VLC.")
 
+#define DAEMON_TEXT N_("Run as daemon proces")
+#define DAEMON_LONGTEXT N_( \
+     "Runs VLC as a background daemon proces.")
+
 #define ONEINSTANCE_TEXT N_("Allow only one running instance")
 #define ONEINSTANCE_LONGTEXT N_( \
     "Allowing only one running instance of VLC can sometimes be useful, " \
@@ -966,10 +970,16 @@ vlc_module_begin();
                 DEMUX_LONGTEXT, VLC_TRUE );
     add_bool( "minimize-threads", 0, NULL, MINIMIZE_THREADS_TEXT,
               MINIMIZE_THREADS_LONGTEXT, VLC_TRUE );
-    add_directory( "plugin-path", NULL, NULL, PLUGIN_PATH_TEXT,
-                   PLUGIN_PATH_LONGTEXT, VLC_TRUE );
     add_bool( "plugins-cache", 0, NULL, PLUGINS_CACHE_TEXT,
               PLUGINS_CACHE_LONGTEXT, VLC_TRUE );
+    add_directory( "plugin-path", NULL, NULL, PLUGIN_PATH_TEXT,
+                   PLUGIN_PATH_LONGTEXT, VLC_TRUE );
+
+#if !defined(WIN32)
+    add_bool( "daemon", 0, NULL, DAEMON_TEXT,
+              DAEMON_LONGTEXT, VLC_TRUE );
+        change_short('d');
+#endif
 
 #if !defined(SYS_DARWIN) && !defined(SYS_BEOS) && defined(PTHREAD_COND_T_IN_PTHREAD_H)
     add_bool( "rt-priority", 0, NULL, RT_PRIORITY_TEXT,