From 6a9cbc9600ce0394e69a360ab683ad14407e98fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Wed, 5 Apr 2006 19:36:20 +0200 Subject: [PATCH] Attempt workaround for FreeBSD bugs... Rev: src/signal_handler.c:1.316 --- src/signal_handler.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/signal_handler.c b/src/signal_handler.c index d250750a67..568011ea2e 100644 --- a/src/signal_handler.c +++ b/src/signal_handler.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: signal_handler.c,v 1.315 2005/12/02 20:43:04 grubba Exp $ +|| $Id: signal_handler.c,v 1.316 2006/04/05 17:36:20 grubba Exp $ */ #include "global.h" @@ -3433,6 +3433,7 @@ void f_create_process(INT32 args) errnum); } else if(pid) { int olderrno; + int cnt = 0; PROC_FPRINTF((stderr, "[%d] Parent\n", getpid())); @@ -3521,8 +3522,16 @@ void f_create_process(INT32 args) PROC_FPRINTF((stderr, "[%d] Parent: Wait for child...\n", getpid())); /* Wait for exec or error */ +#if defined(EBADF) && defined(EPIPE) + /* Attempt to workaround spurious errors from read(2) on FreeBSD. */ + while (((e = read(control_pipe[0], buf, 3)) < 0) && + (errno != EBADF) && (errno != EPIPE) && (cnt++ < 16)) + ; +#else /* !EBADF || !EPIPE */ + /* This code *should* work... */ while (((e = read(control_pipe[0], buf, 3)) < 0) && (errno == EINTR)) ; +#endif /* EBADF && EPIPE */ /* Paranoia in case close() sets errno. */ olderrno = errno; -- GitLab