release x11 connection for nvidia when quitting psensor
authorJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 13 Jun 2011 07:34:31 +0000 (07:34 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 13 Jun 2011 07:34:31 +0000 (07:34 +0000)
src/lib/nvidia.c
src/lib/nvidia.h
src/main.c

index a8060c3..54ad724 100644 (file)
@@ -75,6 +75,13 @@ static struct psensor *create_sensor(int id, int values_len)
        return s;
 }
 
+static void close_display()
+{
+       XCloseDisplay(display);
+       display = NULL;
+
+}
+
 /*
   Opens connection to X server and returns the number
   of NVidia GPUs.
@@ -139,3 +146,9 @@ nvidia_psensor_list_add(struct psensor **sensors, int values_len)
 
        return ss;
 }
+
+void nvidia_cleanup()
+{
+       if (display) 
+               close_display();
+}
index 1aafe69..d046928 100644 (file)
@@ -37,4 +37,6 @@ struct psensor **nvidia_psensor_list_add(struct psensor **sensors,
                                         int values_max_length);
 
 
+void nvidia_cleanup();
+
 #endif
index 933784a..b9c8473 100644 (file)
@@ -408,5 +408,9 @@ int main(int argc, char **argv)
 
        psensor_list_free(ui.sensors);
 
+#ifdef HAVE_NVIDIA
+       nvidia_cleanup();
+#endif
+
        return 0;
 }