Merge lp://qastaging/~bratsche/xsplash/daemon-0.7 into lp://qastaging/~bratsche/xsplash/release-0.7

Proposed by Cody Russell
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~bratsche/xsplash/daemon-0.7
Merge into: lp://qastaging/~bratsche/xsplash/release-0.7
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~bratsche/xsplash/daemon-0.7
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+11808@code.qastaging.launchpad.net
To post a comment you must log in.
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-10 17:23:19 +0000
3+++ src/xsplash.c 2009-09-15 16:55:47 +0000
4@@ -73,6 +73,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@@ -127,6 +128,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@@ -143,6 +145,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@@ -446,6 +453,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
41@@ -696,6 +705,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

to all changes: