Ejemplo n.º 1
0
static void
_register_signal_handler(struct iv_signal *signal_poll, gint signum, void (*handler)(void *))
{
  IV_SIGNAL_INIT(signal_poll);
  signal_poll->signum = signum;
  signal_poll->flags = IV_SIGNAL_FLAG_EXCLUSIVE;
  signal_poll->cookie = NULL;
  signal_poll->handler = handler;
  iv_signal_register(signal_poll);
}
Ejemplo n.º 2
0
int main()
{
	long long nsec;

	iv_init();

#ifdef USE_SIGNAL
	signal(SIGALRM, got_signal_timeout);
	alarm(5);
#else
	IV_TIMER_INIT(&timeout);
	iv_validate_now();
	timeout.expires = iv_now;
	timeout.expires.tv_sec += 5;
	timeout.handler = got_timer_timeout;
	iv_timer_register(&timeout);
#endif

	IV_SIGNAL_INIT(&is);
	is.signum = SIGUSR1;
	is.handler = got_sig;
	iv_signal_register(&is);

	iv_validate_now();
	tim_start = iv_now;

	raise(SIGUSR1);

	iv_main();

	iv_deinit();

	nsec = 1000000000ULL * (tim_end.tv_sec - tim_start.tv_sec) +
		(tim_end.tv_nsec - tim_start.tv_nsec);

	printf("%s: %d in %ld nsec => %d/sec\n",
	       iv_poll_method_name(), sig_received, (long)nsec,
	       (int)(1000000000ULL * sig_received / nsec));

	return 0;
}