void run_gui(char *gui_xdisplay, int connect_to_x11vnc) {
void run_gui(char *gui_xdisplay, int connect_to_x11vnc, pid_t parent) {
void run_gui(char *gui_xdisplay, int connect_to_x11vnc) {	char *x11vnc_xdisplay = NULL;	char extra_path[] = ":/usr/local/bin:/usr/bin/X11:/usr/sfw/bin"	    ":/usr/X11R6/bin:/usr/openwin/bin:/usr/dt/bin";	char cmd[100];	char *wish = NULL, *orig_path, *full_path, *tpath, *p;	int try_max = 9, sleep = 300;	FILE *pipe;	if (getenv("DISPLAY") != NULL) {		x11vnc_xdisplay = strdup(getenv("DISPLAY"));	}	if (use_dpy) {		x11vnc_xdisplay = strdup(use_dpy);	}	if (connect_to_x11vnc) {		int rc, i;		rfbLogEnable(0);		if (! client_connect_file) {			dpy = XOpenDisplay(x11vnc_xdisplay); 			if (! dpy) {				fprintf(stderr, "gui: could not open display: %s\n",				    x11vnc_xdisplay);				exit(1);			}			scr = DefaultScreen(dpy);			rootwin = RootWindow(dpy, scr);			initialize_vnc_connect_prop();		}		usleep(1000*1000);		for (i=0; i<try_max; i++) {			usleep(sleep*1000);			fprintf(stderr, "gui: pinging %s try=%d ...\n",			    NONUL(x11vnc_xdisplay), i+1);			rc = send_remote_cmd("qry=ping", 1, 1);			if (rc == 0) {				break;			}		}		if (rc == 0) {			fprintf(stderr, "gui: ping succeeded.\n");			set_env("X11VNC_XDISPLAY", x11vnc_xdisplay);			set_env("X11VNC_CONNECT", "1");		} else {			fprintf(stderr, "gui: could not connect to: '%s', try"			    " again manually.\n", x11vnc_xdisplay);		}	}	orig_path = getenv("PATH");	if (! orig_path) {		orig_path = strdup("/bin:/usr/bin:/usr/bin/X11");	}	full_path = (char *) malloc(strlen(orig_path)+strlen(extra_path)+1);	strcpy(full_path, orig_path);	strcat(full_path, extra_path);	tpath = strdup(full_path);	p = strtok(tpath, ":");	while (p) {		char *try;		struct stat sbuf;		char *wishes[] = {"wish", "wish8.3", "wish8.4"};		int nwishes = 3, i;		try = (char *)malloc(strlen(p) + 10);		for (i=0; i<nwishes; i++) {			sprintf(try, "%s/%s", p, wishes[i]);			if (stat(try, &sbuf) == 0) {				/* assume executable, should check mode */				wish = wishes[i];			}		}		free(try);		if (wish) {			break;		}		p = strtok(NULL, ":");	}	free(tpath);	if (!wish) {		wish = strdup("wish");	}	set_env("PATH", full_path);	set_env("DISPLAY", gui_xdisplay);	set_env("X11VNC_PROG", program_name);	set_env("X11VNC_CMDLINE", program_cmdline);	sprintf(cmd, "%s -", wish);	pipe = popen(cmd, "w");	if (! pipe) {		fprintf(stderr, "could not run: %s\n", cmd);		perror("popen");	}	fprintf(pipe, "%s", gui_code);	pclose(pipe);	exit(0);}