Esempio n. 1
0
/*
 * Normal exiting
 */
void clean_up_exit (int ret) {
	static int depth = 0;
	exit_flag = 1;

	if (depth++ > 2) {
		exit(ret);
	}

	if (icon_mode) {
		clean_icon_mode();
	}

	/* remove the shm areas: */
	clean_shm(0);

	stop_stunnel();
	if (use_openssl) {
		ssl_helper_pid(0, 0);	/* killall */
	}

	if (! dpy) exit(ret);	/* raw_rb hack */

	/* X keyboard cleanups */
	delete_added_keycodes(0);

	if (clear_mods == 1) {
		clear_modifiers(0);
	} else if (clear_mods == 2) {
		clear_keys();
	}

	if (no_autorepeat) {
		autorepeat(1, 0);
	}
	if (use_solid_bg) {
		solid_bg(1);
	}
	X_LOCK;
	XTestDiscard_wr(dpy);
#if LIBVNCSERVER_HAVE_LIBXDAMAGE
	if (xdamage) {
		XDamageDestroy(dpy, xdamage);
	}
#endif
#if LIBVNCSERVER_HAVE_LIBXTRAP
	if (trap_ctx) {
		XEFreeTC(trap_ctx);
	}
#endif
	/* XXX rdpy_ctrl, etc. cannot close w/o blocking */
	XCloseDisplay_wr(dpy);
	X_UNLOCK;

	fflush(stderr);
	exit(ret);
}
Esempio n. 2
0
/*
 * Normal exiting
 */
void clean_up_exit(int ret) {
	static int depth = 0;
	exit_flag = 1;

	if (depth++ > 2) {
		exit(ret);
	}

	if (icon_mode) {
		clean_icon_mode();
	}

	/* remove the shm areas: */
	clean_shm(0);

	stop_stunnel();
	if (use_openssl) {
		ssl_helper_pid(0, 0);	/* killall */
	}

	if (ssh_pid > 0) {
		kill(ssh_pid, SIGTERM);
		ssh_pid = 0;
	}

#ifdef MACOSX
	if (client_connect_file) {
		if (strstr(client_connect_file, "/tmp/x11vnc-macosx-remote")
		    == client_connect_file) {
			unlink(client_connect_file);
		}
	}
	if (macosx_console) {
		macosxCG_fini();
	}
#endif

	if (pipeinput_fh != NULL) {
		pclose(pipeinput_fh);
		pipeinput_fh = NULL;
	}


	shutdown_uinput();

	if (unix_sock) {
		if (unix_sock_fd >= 0) {
			rfbLog("deleting unix sock: %s\n", unix_sock);
			close(unix_sock_fd);
			unix_sock_fd = -1;
			unlink(unix_sock);
		}
	}

	if (! dpy) {	/* raw_rb hack */
		if (rm_flagfile) {
			unlink(rm_flagfile);
			rm_flagfile = NULL;
		}
		exit(ret);
	}

	/* X keyboard cleanups */
	delete_added_keycodes(0);

	if (clear_mods == 1) {
		clear_modifiers(0);
	} else if (clear_mods == 2) {
		clear_keys();
	} else if (clear_mods == 3) {
		clear_keys();
		clear_locks();
	}

	if (no_autorepeat) {
		autorepeat(1, 0);
	}
	if (use_solid_bg) {
		solid_bg(1);
	}
	if (ncache || ncache0) {
		kde_no_animate(1);
	}
	X_LOCK;
	XTestDiscard_wr(dpy);
#if LIBVNCSERVER_HAVE_LIBXDAMAGE
	if (xdamage) {
		XDamageDestroy(dpy, xdamage);
	}
#endif
#if LIBVNCSERVER_HAVE_LIBXTRAP
	if (trap_ctx) {
		XEFreeTC(trap_ctx);
	}
#endif
	/* XXX rdpy_ctrl, etc. cannot close w/o blocking */
	XCloseDisplay_wr(dpy);
	X_UNLOCK;

	fflush(stderr);

	if (rm_flagfile) {
		unlink(rm_flagfile);
		rm_flagfile = NULL;
	}

	if (avahi) {
		avahi_cleanup();
		fflush(stderr);
	}

	exit(ret);
}