Only ever fork() once.
authorBrenden Matthews <brenden@diddyinc.com>
Tue, 26 Jan 2010 21:05:04 +0000 (13:05 -0800)
committerBrenden Matthews <brenden@diddyinc.com>
Tue, 26 Jan 2010 21:05:04 +0000 (13:05 -0800)
src/conky.c

index eef6791..8e29c22 100644 (file)
@@ -353,6 +353,10 @@ static unsigned long total_run_times;
 /* fork? */
 static int fork_to_background;
 
+/* set to 0 after the first time conky is run, so we don't fork again after the
+ * first forking */
+static int first_pass = 1;
+
 static int cpu_avg_samples, net_avg_samples, diskio_avg_samples;
 
 /* filenames for output */
@@ -5615,7 +5619,7 @@ void initialisation(int argc, char **argv) {
 
        while (1) {
                int c = getopt_long(argc, argv, getopt_string, longopts, NULL);
-               static int startup_pause = 0;
+               int startup_pause;
 
                if (c == -1) {
                        break;
@@ -5678,7 +5682,7 @@ void initialisation(int argc, char **argv) {
                                break;
 #endif /* X11 */
                        case 'p':
-                               if (startup_pause == 0) {
+                               if (first_pass) {
                                        startup_pause = atoi(optarg);
                                        sleep(startup_pause);
                                }
@@ -5704,7 +5708,7 @@ void initialisation(int argc, char **argv) {
        }
        global_text = NULL;
        /* fork */
-       if (fork_to_background) {
+       if (fork_to_background && first_pass) {
                int pid = fork();
 
                switch (pid) {
@@ -5912,6 +5916,8 @@ int main(int argc, char **argv)
 
        initialisation(argc, argv);
 
+       first_pass = 0; /* don't ever call fork() again */
+
        main_loop();
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)