static gboolean signal_handler(GIOChannel *channel, GIOCondition cond, gpointer user_data) { struct signalfd_siginfo si; ssize_t result; int fd; if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) return FALSE; fd = g_io_channel_unix_get_fd(channel); result = read(fd, &si, sizeof(si)); if (result != sizeof(si)) return FALSE; switch (si.ssi_signo) { case SIGINT: case SIGTERM: do_terminate(); break; } return TRUE; }
void process_indicators(tokens fields) { interp_list *current; interp_list *previous; /* Loop through each node in the list of interpretations */ current = interp_header->next_interp; previous = interp_header; while (current != NULL) { /* Perform the action corresponding to the indicator */ switch(current->indicator) { case '^': current = do_split(current); break; case '-': current = do_terminate(current,previous); break; case 'x': current = do_exchange(current); break; case 'v': current = do_join(current); break; case '+': current = do_add(current); break; } previous = current; current = current->next_interp; } }