Beispiel #1
0
int init_ipc(void)
{
	int optval;

	/* create the pipe for dispatching the timer jobs */
	if (pipe(ipc_shared_pipe) != 0) {
		LM_ERR("failed to create ipc pipe (%s)!\n", strerror(errno));
		return -1;
	}

	/* make reading fd non-blocking */
	optval = fcntl(ipc_shared_pipe[0], F_GETFL);
	if (optval == -1) {
		LM_ERR("fcntl failed: (%d) %s\n", errno, strerror(errno));
		return -1;
	}

	if (fcntl(ipc_shared_pipe[0], F_SETFL, optval|O_NONBLOCK) == -1) {
		LM_ERR("set non-blocking failed: (%d) %s\n", errno, strerror(errno));
		return -1;
	}

	ipc_shared_fd_read = ipc_shared_pipe[0];

	/* self-register the IPC type for RPC */
	ipc_rpc_type = ipc_register_handler( NULL, "RPC");
	if (ipc_bad_handler_type(ipc_rpc_type)) {
		LM_ERR("failed to self register RPC type\n");
		return -1;
	}

	/* we are all set */
	return 0;
}
Beispiel #2
0
void
signals_init(void)
{
  int r = ipc_register_handler(IPC_UNIX_SIGNALS, unix_signals_h);
  if (r < 0)
  {
    printf("signals_init: cannot register handler for UNIX signals. "
	   "Signals will not work\n");
  }
}
Beispiel #3
0
int main()
{
  ipc_register_handler(MIN_APP_IPC_NUMBER, my_handler);

  if (fork() == 0) /* child */
  {
    client(getppid());
    kill(getppid(), SIGKILL);
  }

  else
  {
    server();
  }

  return 0;
}