Commit f1579f90 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* first stab at vlc daemon mode (-d, --daemon )

parent 10c1b268
......@@ -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;
......
......@@ -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
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment