/** * This function initializes each one of the processes spawn by the server. * the rank is 1 only when the main process is being initialized, so in that * case the function spawns the SEAS process to handle as_events triggered * from the other SER processes (executing the script). * the new process created, then goes into dispatcher_main_loop(), where * it reads() the pipe waiting for events produced by other SER processes. */ static int seas_child_init(int rank) { int pid; /* only the child 1 will execute this */ if (rank != PROC_MAIN){ /* only dispatcher needs to read from the pipe, so close reading fd*/ /*close(read_pipe);*/ return 0; } if ((pid=fork_process(PROC_NOCHLDINIT,"SEAS",0))<0) { LM_ERR("forking failed\n"); return -1; } if (!pid) { /*dispatcher child. we leave writing end open so that new childs spawned * by event dispatcher can also write to pipe.. */ /* initialize the config framework */ if (cfg_child_init()) return -1; /* close(write_pipe); */ return dispatcher_main_loop(); } return 0; }
/** * This function initializes each one of the processes spawn by the server. * the rank is 1 only when the main process is being initialized, so in that * case the function spawns the SEAS process to handle as_events triggered * from the other SER processes (executing the script). * the new process created, then goes into dispatcher_main_loop(), where * it reads() the pipe waiting for events produced by other SER processes. */ static int seas_child_init(int rank) { int pid; /* only the child 1 will execute this */ if (rank != 1){ /* only dispatcher needs to read from the pipe, so close reading fd*/ close(read_pipe); return 0; } if ((pid=fork())<0) { LM_ERR("forking failed\n"); return -1; } if (!pid) { /*dispatcher child. we leave writing end open so that new childs spawned * by event dispatcher can also write to pipe.. */ /* close(write_pipe); */ return dispatcher_main_loop(); } return 0; }