Пример #1
0
static void visual_repeat(RCore *core) {
	int atport = r_config_get_i (core->config, "scr.atport");
	if (atport) {
#if __UNIX__ && !__APPLE__
		int port = r_config_get_i (core->config, "http.port");
		if (!r_core_rtr_http (core, '&', NULL)) {
			const char *xterm = r_config_get (core->config, "cmd.xterm");
			// TODO: this must be configurable
			r_sys_cmdf ("%s 'r2 -C http://localhost:%d/cmd/V;sleep 1' &", xterm, port);
			//xterm -bg black -fg gray -e 'r2 -C http://localhost:%d/cmd/;sleep 1' &", port);
		} else {
			r_cons_any_key (NULL);
		}
#else
		eprintf ("Unsupported on this platform\n");
		r_cons_any_key (NULL);
#endif
	} else {
		RThread *th = r_th_new (visual_repeat_thread, core, 0);
		r_th_start (th, 1);
		r_cons_break (NULL, NULL);
		r_cons_any_key (NULL);
		eprintf ("^C  \n");
		core->cons->breaked = true;
		r_th_wait (th);
		r_cons_break_end ();
	}
}
Пример #2
0
int test1() {
	int ctr = 0;
	struct r_th_t *th;

	th = r_th_new (&looper, &ctr, 0);
	th = r_th_new (&looper, &ctr, 0);
	//th = r_th_new (&looper, &ctr, 0);

#if __i386__ || __x86_64__
	asm ("int3");
#endif
	//r_th_start (th, true);
	while (r_th_wait_async (th)) {
		printf ("\nwaiting...\n");
		fflush (stdout);
		r_sys_usleep (400);
		//	r_th_break(th);
	}
	printf ("\nfinished\n");
#if 0
	r_th_start(th, true);
	sleep(1);
#endif
	/* wait and free */
	r_th_wait (th);
	r_th_free (th);

	printf ("\nresult %d\n", ctr);
	return 0;
}
Пример #3
0
R_API int r_th_kill(RThread *th, int force) {
	th->breaked = true;
	r_th_break(th);
	r_th_wait(th);
#if HAVE_PTHREAD
#ifdef __ANDROID__
	pthread_kill (th->tid, 9);
#else
	pthread_cancel (th->tid);
#endif
#elif __WINDOWS__ && !defined(__CYGWIN__)
	TerminateThread (th->tid, -1);
#endif
	return 0;
}
Пример #4
0
R_API bool r_th_kill(RThread *th, bool force) {
	if (!th || !th->tid) {
		return false;
	}
	th->breaked = true;
	r_th_break (th);
	r_th_wait (th);
#if HAVE_PTHREAD
#ifdef __ANDROID__
	pthread_kill (th->tid, 9);
#else
	pthread_cancel (th->tid);
#endif
#elif __WINDOWS__
	TerminateThread (th->tid, -1);
#endif
	return 0;
}