[vlc-devel] [PATCH 1/2] Remove --daemon

RĂ©mi Denis-Courmont remi at remlab.net
Mon Mar 30 15:37:34 CEST 2020


Forking the process after LibVLC has already used threading is not
possible, so this has not been working for years, if it ever worked.

Some users do run VLC in the background, but they generally have their
own wrappers, and/or use dedicated job management such as upstart or
systemd. daemon() has the fatal problem that it prevents checking
for error returns (early exit) as well as the standard error.

This also removes --pidfile since it's a no-op without --daemon.
---
 src/interface/interface.c | 10 +++-------
 src/libvlc-module.c       | 14 ++------------
 src/libvlc.c              | 29 -----------------------------
 3 files changed, 5 insertions(+), 48 deletions(-)

diff --git a/src/interface/interface.c b/src/interface/interface.c
index 96fa792921..cc490a35f2 100644
--- a/src/interface/interface.c
+++ b/src/interface/interface.c
@@ -253,13 +253,9 @@ int libvlc_InternalAddIntf(libvlc_int_t *libvlc, const char *name)
     {   /* Default interface */
         char *intf = var_InheritString(libvlc, "intf");
         if (intf == NULL) /* "intf" has not been set */
-        {
-#if !defined(_WIN32) && !defined(__OS2__)
-            if (!var_InheritBool(libvlc, "daemon"))
-#endif
-                msg_Info(libvlc, _("Running vlc with the default interface. "
-                         "Use 'cvlc' to use vlc without interface."));
-        }
+            msg_Info(libvlc, _("Running vlc with the default interface. "
+                     "Use 'cvlc' to use vlc without interface."));
+
         ret = intf_Create(libvlc, intf);
         free(intf);
         name = "default";
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 1da7fa6e79..979f3893ac 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1133,14 +1133,6 @@ static const char *const ppsz_prefres[] = {
 #define STATS_LONGTEXT N_( \
      "Collect miscellaneous local statistics about the playing media.")
 
-#define DAEMON_TEXT N_("Run as daemon process")
-#define DAEMON_LONGTEXT N_( \
-     "Runs VLC as a background daemon process.")
-
-#define PIDFILE_TEXT N_("Write process id to file")
-#define PIDFILE_LONGTEXT N_( \
-       "Writes process id into specified file.")
-
 #define ONEINSTANCE_TEXT N_("Allow only one running instance")
 #define ONEINSTANCE_LONGTEXT N_( \
     "Allowing only one running instance of VLC can sometimes be useful, " \
@@ -2272,11 +2264,9 @@ vlc_module_begin ()
         change_volatile ()
     add_obsolete_string( "verbose-objects" ) /* since 2.1.0 */
 #if !defined(_WIN32) && !defined(__OS2__)
-    add_bool( "daemon", 0, DAEMON_TEXT, DAEMON_LONGTEXT, true )
+    add_obsolete_bool( "daemon" ) /* since 4.0.0 */
         change_short('d')
-
-    add_string( "pidfile", NULL, PIDFILE_TEXT, PIDFILE_LONGTEXT,
-                                       false )
+    add_obsolete_string( "pidfile" ) /* since 4.0.0 */
 #endif
 
 #if defined (_WIN32) || defined (__APPLE__)
diff --git a/src/libvlc.c b/src/libvlc.c
index c1a6e574d4..c23cf8b870 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -182,35 +182,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         exit(0);
     }
 
-#ifdef HAVE_DAEMON
-    /* Check for daemon mode */
-    if( var_InheritBool( p_libvlc, "daemon" ) )
-    {
-        if( daemon( 1, 0) != 0 )
-        {
-            msg_Err( p_libvlc, "Unable to fork vlc to daemon mode" );
-            goto error;
-        }
-
-        /* lets check if we need to write the pidfile */
-        char *pidfile = var_InheritString( p_libvlc, "pidfile" );
-        if( pidfile != NULL )
-        {
-            FILE *stream = vlc_fopen( pidfile, "w" );
-            if( stream != NULL )
-            {
-                fprintf( stream, "%d", (int)getpid() );
-                fclose( stream );
-                msg_Dbg( p_libvlc, "written PID file %s", pidfile );
-            }
-            else
-                msg_Err( p_libvlc, "cannot write PID file %s: %s",
-                         pidfile, vlc_strerror_c(errno) );
-            free( pidfile );
-        }
-    }
-#endif
-
     i_ret = VLC_ENOMEM;
 
     if( libvlc_InternalDialogInit( p_libvlc ) != VLC_SUCCESS )
-- 
2.26.0



More information about the vlc-devel mailing list