minor mkxsock improvements
authorTomas Mudrunka <tomas@mudrunka.cz>
Thu, 19 Apr 2012 14:50:03 +0000 (16:50 +0200)
committerTomas Mudrunka <tomas@mudrunka.cz>
Thu, 19 Apr 2012 14:50:03 +0000 (16:50 +0200)
c/vizionix/mkxsock.c

index 74cb99bcfa5feeaa6367c9248772eb25a0e705dd..c3d076bceed54be655439ceebed2373a6e420249 100644 (file)
@@ -3,6 +3,8 @@
 #include <getopt.h>
 #include <gtk/gtk.h>
 
+#define ENV_PREFIX "XSOCK_"
+
 int return_true(void) { return 1; }
 
 void print_help(char ** argv) {
@@ -12,6 +14,7 @@ void print_help(char ** argv) {
                "\t -c color\n"
                "\t -w width\n"
                "\t -h height\n"
+               //"\t -r reuse " ENV_PREFIX "* from environment\n"
                "\t -? (display help)"
                "\nExample: %s -c black -w 640 -h 480\n\n",
                argv[0], argv[0]);
@@ -35,6 +38,15 @@ gint main(gint argc, gchar ** argv)
                        case 'h':
                                height = atoi(optarg);
                                break;
+                       case 'r': //Not yet
+                               if(getenv(ENV_PREFIX"PID")
+                                       && getenv(ENV_PREFIX"WID")
+                                       && kill(atoi(getenv(ENV_PREFIX"PID")), 0)
+                               ) {
+                                       puts("REUSABLE");
+                                       return 0;
+                               }
+                               break;
                        case '?':
                                print_help(argv);
                                return 0;
@@ -64,7 +76,7 @@ gint main(gint argc, gchar ** argv)
        GdkNativeWindow wid = gtk_socket_get_id(GTK_SOCKET(sock));
        int pid;
        if ((pid = fork())) {
-               printf("XSOCK_WID=%d\nXSOCK_PID=%d\n", wid, pid);
+               printf(ENV_PREFIX"WID=%d\n"ENV_PREFIX"PID=%d\n", wid, pid);
                return 0;
        }
        fclose(stdout);
This page took 0.106296 seconds and 4 git commands to generate.