updated on Fri Jan 6 08:01:17 UTC 2012
[aur-mirror.git] / nodm / norestart.patch
blob0e07096f2e3e0b9829a560057676ded8dd6b3c67
1 diff -aur nodm-0.7/nodm.c nodm-0.7-new/nodm.c
2 --- nodm-0.7/nodm.c 2009-07-26 20:36:14.000000000 +0200
3 +++ nodm-0.7-new/nodm.c 2011-03-02 15:19:23.960000382 +0100
4 @@ -427,8 +427,10 @@
5 * @param mst
6 * The minimum time (in seconds) that a session should last to be considered
7 * successful
8 + * @param xrestart
9 + * Boolean option whether to restart X or not
11 -void run_and_restart(const char* xinit, const char* xsession, const char* xoptions, int mst)
12 +void run_and_restart(const char* xinit, const char* xsession, const char* xoptions, int mst, int xrestart)
14 static int retry_times[] = { 0, 0, 30, 30, 60, 60, -1 };
15 int restart_count = 0;
16 @@ -446,8 +448,7 @@
17 args[2] = command;
18 args[3] = 0;
20 - while (1)
21 - {
22 + do {
23 /* Run the X server */
24 time_t begin = time(NULL);
25 time_t end;
26 @@ -470,7 +471,7 @@
27 /* Sleep a bit if the session was too short */
28 sleep(retry_times[restart_count]);
29 syslog (LOG_INFO, "Restarting session for %s", name);
30 - }
31 + } while (xrestart);
35 @@ -525,6 +526,7 @@
36 int mst;
37 int vt_fd = -1;
38 int vt_num;
39 + int xrestart = 0;
41 /* Parse command line options */
42 while (1)
43 @@ -576,6 +578,8 @@
44 /* Read the configuration from the environment */
45 cp = getenv("NODM_MIN_SESSION_TIME");
46 mst = cp ? atoi(cp) : 60;
47 + cp = getenv("NODM_RESTART_SESSION");
48 + xrestart = cp ? atoi(cp) : 0;
49 string_from_env(xinit, "NODM_XINIT", "/usr/bin/xinit");
50 string_from_env(xoptions, "NODM_X_OPTIONS", "");
52 @@ -585,7 +589,7 @@
53 snprintf(xoptions1, BUFSIZ, "vt%d %s", vt_num, xoptions);
55 setenv("NODM_RUN_SESSION", "1", 1);
56 - run_and_restart(xinit, opt_session, xoptions1, mst);
57 + run_and_restart(xinit, opt_session, xoptions1, mst, xrestart);
59 close(vt_fd);