Commit 521e2124 authored by Gildas Bazin's avatar Gildas Bazin

* src/libvlc.c: use dameon() instead of fork() when available. It does some...

* src/libvlc.c: use dameon() instead of fork() when available. It does some more things like reopening stdin/out/err to /dev/null which avoids screwing up the first sockets we open.
parent 5f631245
......@@ -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
......
......@@ -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
......
......@@ -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
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