X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=signal.h;h=742f677a2568cad3001ae9cc2220344ebf7f8b1b;hp=50c5f636a84168f637ae26db9a41086d5177580f;hb=c257c9c321c6e9494dbcbb6da0af675c3a2aa8e4;hpb=471684761a2039bbc89aa1e3c33c62de6bef86cf diff --git a/signal.h b/signal.h index 50c5f636..742f677a 100644 --- a/signal.h +++ b/signal.h @@ -1,13 +1,48 @@ /* - * Copyright (C) 2007 Andre Noll + * Copyright (C) 2007 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ /** \file signal.h exported symbols from signal.c */ -int para_signal_init(void); -int para_install_sighandler(int); -void para_reap_children(void); -pid_t para_reap_child(void); -int para_next_signal(void); +/** + * Task for signal handling. + */ +struct signal_task { + /** The signal pipe. */ + int fd; + /** The associated task structure. */ + struct task *task; +}; + +/** + * A generic pre-select method for signal tasks. + * + * \param s Passed to para_fd_set(). + * \param context Signal task pointer. + * + * This convenience helper is called from several programs which need to handle + * signals, including para_server and para_audiod. These programs define a + * signal task structure and set its ->pre_select method to this function which + * adds the file descriptor of the signal task to the set of descriptors to be + * watched in the next select() call. + * + * Although the second parameter must be in fact a pointer to a signal_task + * structure, the parameter is specified as void * here to match the + * ->pre_select method of struct task. + */ +_static_inline_ void signal_pre_select(struct sched *s, void *context) +{ + struct signal_task *st = context; + para_fd_set(st->fd, &s->rfds, &s->max_fileno); +} + +struct signal_task *signal_init_or_die(void); +void para_sigaction(int sig, void (*handler)(int)); +void para_install_sighandler(int); +int para_reap_child(pid_t *pid); +int para_next_signal(fd_set *rfds); +void signal_shutdown(struct signal_task *st); +void para_block_signal(int sig); +void para_unblock_signal(int sig);