From: Tomas Mudrunka Date: Thu, 19 Apr 2012 14:50:03 +0000 (+0200) Subject: minor mkxsock improvements X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=27b92eddf04b010aa9ca2fe682d743e5f15dae4c;p=mirrors%2FPrograms.git minor mkxsock improvements --- diff --git a/c/vizionix/mkxsock.c b/c/vizionix/mkxsock.c index 74cb99b..c3d076b 100644 --- a/c/vizionix/mkxsock.c +++ b/c/vizionix/mkxsock.c @@ -3,6 +3,8 @@ #include #include +#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);