static void sig_handler(int signum, siginfo_t *info, void *ucontext) { journal_strace("sig_handler"); sigset_t block_mask, old_mask; sigfillset(&block_mask); sigprocmask(SIG_BLOCK, &block_mask, &old_mask); switch (signum) { case SIGSEGV: journal_notice("event]> caught SIGSEGV :: %s:%i\n", __FILE__, __LINE__); event_throw(EVENT_EXIT, NULL); break; case SIGINT: journal_notice("event]> caught SIGINT :: %s:%i\n", __FILE__, __LINE__); event_throw(EVENT_EXIT, NULL); break; case SIGALRM: event_throw(EVENT_SCHED, NULL); break; } sigprocmask(SIG_SETMASK, &old_mask, NULL); return; }
static int local_command(char *line) { if (!strcmp(line, ".quit")) { event_throw(EVENT_EXIT, NULL); } return 0; }
static void close_socket(usocket_t *sck) { cli_console_t *console; console = sck->udata; usocket_close(sck); console->socket->socket = NULL; event_throw(EVENT_EXIT, NULL); }
int main(void) { int cnt = 0; char eventa[4] = "ab\0"; char eventb[4] = "bcd\0"; char eventc[4] = "cde\0"; char eventd[4] = "d\0"; char *events[] = {eventa, eventb, eventc, eventd}; int rt, e0, e1, e2, e3; int tab[4]; pid_t pid; print_test_scenario(); pid = fork(); switch(pid) { case 0: proc2(); break; default: printf("proc1: event_set\n"); e0 = event_set(eventa); event_check_error_exit(e0, "proc1: event_set"); e1 = event_set(eventb); event_check_error_exit(e1, "proc1: event_set"); e2 = event_set(eventc); event_check_error_exit(e2, "proc1: event_set"); e3 = event_set(eventd); event_check_error_exit(e3, "proc1: event_set"); tab[0] = e0; tab[1] = e1; tab[2] = e2; tab[3] = e3; sleep(1); while(cnt < 4) { sleep(1); printf("proc1: event_throw, event %s\n", events[cnt]); rt = event_throw(tab[cnt]); event_check_error_exit(rt, "proc2: event_throw FAILS!"); cnt++; } printf("proc1: Unsetting events\n"); rt = event_unset(e0); event_check_error(rt, "proc1: event_unset event0"); rt = event_unset(e1); event_check_error(rt, "proc1: event_unset event1"); rt = event_unset(e2); event_check_error(rt, "proc1: event_unset event2"); rt = event_unset(e3); event_check_error(rt, "proc1: event_unset event3"); sleep(1); printf("proc1: returning\n"); exit(0); } return 0; }