ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #00175
[Merge] lp:~bratsche/xsplash/daemon into lp:xsplash
Cody Russell has proposed merging lp:~bratsche/xsplash/daemon into lp:xsplash.
--
https://code.launchpad.net/~bratsche/xsplash/daemon/+merge/11733
Your team ayatana-commits is subscribed to branch lp:xsplash.
=== modified file 'src/xsplash.c'
--- src/xsplash.c 2009-09-08 16:11:32 +0000
+++ src/xsplash.c 2009-09-14 20:25:30 +0000
@@ -71,6 +71,7 @@
PROP_DBUS_PROXY
};
+static void start_daemon_mode (void);
static AnimContext * anim_context_new (XsplashServer *server,
GtyTimeline *timeline,
gpointer id);
@@ -125,6 +126,7 @@
static guint throbber_frames = 50;
static gboolean ping_pong = FALSE;
static gboolean have_xcomposite = FALSE;
+static gboolean daemon_mode = FALSE;
static gboolean is_composited = FALSE;
static gboolean redirected = FALSE;
static GSList *signal_list = NULL;
@@ -141,6 +143,11 @@
"Filename for background image", NULL
},
{
+ "daemon", 'd', 0,
+ G_OPTION_ARG_NONE, &daemon_mode,
+ "Run in daemon mode", NULL
+ },
+ {
"logo", 'l', 0,
G_OPTION_ARG_FILENAME, &logo_image,
"Filename for logo image", NULL
@@ -558,6 +565,8 @@
gtk_container_add (GTK_CONTAINER (priv->window), fixed);
+ start_daemon_mode ();
+
gtk_widget_show_all (priv->window);
if (logo_filename)
@@ -814,6 +823,27 @@
gtk_main_quit ();
}
+static void
+start_daemon_mode (void)
+{
+ pid_t pid, sid;
+
+ if (daemon_mode)
+ {
+ /* fork from our parent process */
+ pid = fork ();
+
+ if (pid < 0)
+ exit (EXIT_FAILURE);
+
+ if (pid > 0)
+ exit (EXIT_SUCCESS);
+
+ sid = setsid ();
+ if (sid < 0)
+ exit (EXIT_FAILURE);
+ }
+}
#define XSPLASH_LOG "/var/log/gdm/xsplash.log"
References