Merge lp:~bratsche/xsplash/daemon into lp:xsplash

Proposed by Cody Russell
Status: Merged
Merged at revision: not available
Proposed branch: lp:~bratsche/xsplash/daemon
Merge into: lp:xsplash
Diff against target: None lines
To merge this branch: bzr merge lp:~bratsche/xsplash/daemon
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Scott James Remnant (Canonical) (community) Approve
Review via email: mp+11734@code.launchpad.net

This proposal supersedes a proposal from 2009-09-14.

To post a comment you must log in.
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) :
review: Approve
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/xsplash.c'
2--- src/xsplash.c 2009-09-08 16:11:32 +0000
3+++ src/xsplash.c 2009-09-14 20:25:30 +0000
4@@ -71,6 +71,7 @@
5 PROP_DBUS_PROXY
6 };
7
8+static void start_daemon_mode (void);
9 static AnimContext * anim_context_new (XsplashServer *server,
10 GtyTimeline *timeline,
11 gpointer id);
12@@ -125,6 +126,7 @@
13 static guint throbber_frames = 50;
14 static gboolean ping_pong = FALSE;
15 static gboolean have_xcomposite = FALSE;
16+static gboolean daemon_mode = FALSE;
17 static gboolean is_composited = FALSE;
18 static gboolean redirected = FALSE;
19 static GSList *signal_list = NULL;
20@@ -141,6 +143,11 @@
21 "Filename for background image", NULL
22 },
23 {
24+ "daemon", 'd', 0,
25+ G_OPTION_ARG_NONE, &daemon_mode,
26+ "Run in daemon mode", NULL
27+ },
28+ {
29 "logo", 'l', 0,
30 G_OPTION_ARG_FILENAME, &logo_image,
31 "Filename for logo image", NULL
32@@ -558,6 +565,8 @@
33
34 gtk_container_add (GTK_CONTAINER (priv->window), fixed);
35
36+ start_daemon_mode ();
37+
38 gtk_widget_show_all (priv->window);
39
40 if (logo_filename)
41@@ -814,6 +823,27 @@
42 gtk_main_quit ();
43 }
44
45+static void
46+start_daemon_mode (void)
47+{
48+ pid_t pid, sid;
49+
50+ if (daemon_mode)
51+ {
52+ /* fork from our parent process */
53+ pid = fork ();
54+
55+ if (pid < 0)
56+ exit (EXIT_FAILURE);
57+
58+ if (pid > 0)
59+ exit (EXIT_SUCCESS);
60+
61+ sid = setsid ();
62+ if (sid < 0)
63+ exit (EXIT_FAILURE);
64+ }
65+}
66
67 #define XSPLASH_LOG "/var/log/gdm/xsplash.log"
68

Subscribers

People subscribed via source and target branches