예제 #1
0
파일: ipc.c 프로젝트: OpenSIPS/opensips
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;
}
예제 #2
0
파일: signals.c 프로젝트: aunali1/exopc
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");
  }
}
예제 #3
0
파일: ipc.c 프로젝트: aunali1/exopc
int main()
{
  ipc_register_handler(MIN_APP_IPC_NUMBER, my_handler);

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

  else
  {
    server();
  }

  return 0;
}