X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=signal.c;h=acc87802b33a841f8f5d7f90b971ae97a3edc3b0;hp=0490a3a1f10a0897c311bc144ba7ce876652fb14;hb=002731cd3938f3be6b71651e56c062af1adcdec0;hpb=bdf3b7573b4a2ef6a84bdf34442063b32977f54e diff --git a/signal.c b/signal.c index 0490a3a1..acc87802 100644 --- a/signal.c +++ b/signal.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2008 Andre Noll + * Copyright (C) 2004-2009 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -57,8 +57,15 @@ err_out: */ static void generic_signal_handler(int s) { - write(signal_pipe[1], &s, sizeof(int)); - //fprintf(stderr, "got sig %i, write returned %d\n", s, ret); + ssize_t ret = write(signal_pipe[1], &s, sizeof(int)); + + if (ret == sizeof(int)) + return; + if (ret < 0) + PARA_EMERG_LOG("%s\n", strerror(errno)); + else + PARA_EMERG_LOG("short write to signal pipe\n"); + exit(EXIT_FAILURE); } /** @@ -73,7 +80,7 @@ static void generic_signal_handler(int s) * one otherwise. If and only if the function returns one, the content of \a * pid is meaningful. * - * \sa waitpid(2) + * \sa waitpid(2). */ int para_reap_child(pid_t *pid) { @@ -110,12 +117,15 @@ void para_reap_children(void) } /** - * wrapper around signal(2) - * \param sig the number of the signal to catch + * Wrapper around signal(2). + * + * \param sig The number of the signal to catch. * * This installs the generic signal handler for the given signal. + * * \return This function returns 1 on success and \p -E_SIGNAL_SIG_ERR on errors. - * \sa signal(2) + * + * \sa signal(2). */ int para_install_sighandler(int sig) { @@ -152,7 +162,7 @@ int para_next_signal(void) } /** - * Close the signal pipe. + * Close the write end of the signal pipe. */ void para_signal_shutdown(void) {