[2586] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

Re: [PATCH] Handle EINTR during waitpid calls

daemon@ATHENA.MIT.EDU (Nelson Elhage)
Sat Aug 7 16:49:05 2010

From: Nelson Elhage <nelhage@MIT.EDU>
To: Anders Kaseorg <andersk@mit.edu>, barnowl-dev@mit.edu
In-Reply-To: <alpine.DEB.2.00.1008070310490.577@dr-wily.mit.edu>
Date: Sat, 07 Aug 2010 16:49:00 -0400

Reviewed-by: Nelson Elhage <nelhage@mit.edu>

Although it's possible that some of these /do/ want to be interruptible,
but that's a separate issue, since I think the intent here was to make
them uninterruptible and the code isn't prepared to handle unexpected
bailouts.

- Nelson

On Sat, 7 Aug 2010 03:12:35 -0400 (EDT), Anders Kaseorg <andersk@MIT.EDU> wrote:
> Signed-off-by: Anders Kaseorg <andersk@mit.edu>
> ---
>  filterproc.c |    4 +++-
>  popexec.c    |    5 ++++-
>  zcrypt.c     |    4 +++-
>  3 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/filterproc.c b/filterproc.c
> index 6cc0c51..d9b3fda 100644
> --- a/filterproc.c
> +++ b/filterproc.c
> @@ -6,6 +6,7 @@
>  #include <poll.h>
>  #include <fcntl.h>
>  #include <string.h>
> +#include <errno.h>
>  
>  #include <glib.h>
>  
> @@ -91,7 +92,8 @@ int call_filter(const char *prog, const char *const *argv, const char *in, char
>      close(wfd[0]);
>      err = send_receive(rfd[0], wfd[1], in, out);
>      if(err == 0) {
> -      waitpid(pid, status, 0);
> +      while (waitpid(pid, status, 0) == -1 && errno == EINTR)
> +        ;
>      }
>    } else {
>      /* child */
> diff --git a/popexec.c b/popexec.c
> index 53b25aa..d65855d 100644
> --- a/popexec.c
> +++ b/popexec.c
> @@ -6,6 +6,7 @@
>  #include <sys/filio.h>
>  #endif
>  #include <sys/wait.h>
> +#include <errno.h>
>  
>  /* starts up popexec in a new viewwin */
>  owl_popexec *owl_popexec_new(const char *command)
> @@ -158,7 +159,9 @@ void owl_popexec_viewwin_onclose(owl_viewwin *vwin, void *data)
>      /* TODO: we should handle the case where SIGTERM isn't good enough */
>      rv = kill(pe->pid, SIGTERM);
>      owl_function_debugmsg("kill of pid %d returned %d", pe->pid, rv);
> -    rv = waitpid(pe->pid, &status, 0);
> +    do
> +      rv = waitpid(pe->pid, &status, 0);
> +    while (rv == -1 && errno == EINTR);
>      owl_function_debugmsg("waidpid returned %d, status %d", rv, status);
>      pe->pid = 0;
>    }
> diff --git a/zcrypt.c b/zcrypt.c
> index f488a69..16a668f 100644
> --- a/zcrypt.c
> +++ b/zcrypt.c
> @@ -16,6 +16,7 @@
>  #include <stdlib.h>
>  #include <sys/wait.h>
>  #include <ctype.h>
> +#include <errno.h>
>  
>  #include "config.h"
>  
> @@ -565,7 +566,8 @@ FILE *GetZephyrPipe(const char *class, const char *instance, const ZWRITEOPTIONS
>  void CloseZephyrPipe(FILE *pipe)
>  {
>    fclose(pipe);
> -  waitpid(zephyrpipe_pid, NULL, 0);
> +  while (waitpid(zephyrpipe_pid, NULL, 0) == -1 && errno == EINTR)
> +    ;
>    zephyrpipe_pid = 0;
>  }
>  
> -- 
> 1.7.2
> 
> 

home help back first fref pref prev next nref lref last post