~lightdm-team/lightdm/1.4

« back to all changes in this revision

Viewing changes to src/lightdm.c

  • Committer: robert.ancell at canonical
  • Date: 2010-08-23 05:34:31 UTC
  • Revision ID: robert.ancell@canonical.com-20100823053431-eazj1k6ks7xtzj8i
Make pid file configurable

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
static DBusGConnection *bus = NULL;
27
27
static GKeyFile *config_file = NULL;
28
28
static const gchar *config_path = CONFIG_FILE;
 
29
static const gchar *pid_path = "/var/run/lightdm.pid";
29
30
static GMainLoop *loop = NULL;
30
31
static gboolean test_mode = FALSE;
31
32
static gboolean debug = FALSE;
53
54
    g_printerr (/* Description on how to use Light Display Manager displayed on command-line */    
54
55
                _("Help Options:\n"
55
56
                  "  -c, --config <file>             Use configuration file\n"
 
57
                  "      --pid-file <file>           File to write PID into\n"
56
58
                  "  -d, --debug                     Print debugging messages\n"
57
59
                  "      --test-mode                 Run as unprivileged user\n"
58
60
                  "  -v, --version                   Show release version\n"
78
80
               exit (1);
79
81
            }
80
82
            config_path = argv[i];
81
 
        }     
 
83
        }
 
84
        else if (strcmp (arg, "--pid-file"))
 
85
        {
 
86
            i++;
 
87
            if (i == argc)
 
88
            {
 
89
               usage ();
 
90
               exit (1);
 
91
            }
 
92
            pid_path = argv[i];
 
93
        }
82
94
        else if (strcmp (arg, "-d") == 0 ||
83
95
            strcmp (arg, "--debug") == 0) {
84
96
            debug = TRUE;
195
207
    struct sigaction action;
196
208
    GError *error = NULL;
197
209
 
198
 
    /* Write PID file */
199
 
    pid_file = fopen ("/var/run/lightdm.pid", "w");
200
 
    if (pid_file)
201
 
    {
202
 
        fprintf (pid_file, "%d\n", getpid ());
203
 
        fclose (pid_file);
204
 
    }
205
 
 
206
210
    /* Quit cleanly on signals */
207
211
    action.sa_sigaction = signal_cb;
208
212
    sigemptyset (&action.sa_mask);
216
220
 
217
221
    get_options (argc, argv);
218
222
 
 
223
    /* Write PID file */
 
224
    pid_file = fopen (pid_path, "w");
 
225
    if (pid_file)
 
226
    {
 
227
        fprintf (pid_file, "%d\n", getpid ());
 
228
        fclose (pid_file);
 
229
    }
 
230
 
219
231
    if (!test_mode && getuid () != 0)
220
232
    {
221
233
        g_printerr ("Only root can run Light Display Manager\n");