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

Proposed by Cody Russell
Status: Superseded
Proposed branch: lp://qastaging/~bratsche/xsplash/daemon
Merge into: lp://qastaging/xsplash
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~bratsche/xsplash/daemon
Reviewer Review Type Date Requested Status
Canonical Desktop Experience Team Pending
Scott James Remnant (Canonical) Pending
Review via email: mp+11731@code.qastaging.launchpad.net

This proposal has been superseded by a proposal from 2009-09-14.

To post a comment you must log in.
64. By Cody Russell

move fork until after resources are loaded

Unmerged revisions

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 19:58:07 +0000
4@@ -125,6 +125,7 @@
5 static guint throbber_frames = 50;
6 static gboolean ping_pong = FALSE;
7 static gboolean have_xcomposite = FALSE;
8+static gboolean daemon_mode = FALSE;
9 static gboolean is_composited = FALSE;
10 static gboolean redirected = FALSE;
11 static GSList *signal_list = NULL;
12@@ -141,6 +142,11 @@
13 "Filename for background image", NULL
14 },
15 {
16+ "daemon", 'd', 0,
17+ G_OPTION_ARG_NONE, &daemon_mode,
18+ "Run in daemon mode", NULL
19+ },
20+ {
21 "logo", 'l', 0,
22 G_OPTION_ARG_FILENAME, &logo_image,
23 "Filename for logo image", NULL
24@@ -828,6 +834,7 @@
25 guint nameret = 0;
26 struct passwd *pwd;
27 uid_t uid;
28+ pid_t pid, sid;
29
30 pwd = getpwnam (XSPLASH_USER);
31 if (pwd == NULL)
32@@ -850,6 +857,33 @@
33 exit (1);
34 }
35
36+ if (daemon_mode)
37+ {
38+ /* fork from our parent process */
39+ pid = fork ();
40+
41+ if (pid < 0)
42+ exit (EXIT_FAILURE);
43+
44+ if (pid > 0)
45+ exit (EXIT_SUCCESS);
46+
47+ sid = setsid ();
48+ if (sid < 0)
49+ exit (EXIT_FAILURE);
50+
51+ pwd = getpwnam (XSPLASH_USER);
52+ if (pwd == NULL)
53+ {
54+ g_error ("Unknown user: %s", XSPLASH_USER);
55+ return 1;
56+ }
57+
58+ uid = pwd->pw_uid;
59+
60+ setuid (uid);
61+ }
62+
63 gtk_init (&argc, &argv);
64
65 log_init (XSPLASH_LOG); g_message ("xsplash started");

Subscribers

People subscribed via source and target branches