diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 03e8bbe7..a00f6633 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -146,6 +146,7 @@ Artur Skawina Werner Fink for making I/O more robust by handling EINTR for fixing closing all unused file descriptors when opening a pipe + for helping to debug leftover 'zombie' processes when closing a pipe Rolf Hakenes for providing 'libdtv' and adapting the EIT mechanisms to it diff --git a/HISTORY b/HISTORY index 50107fe8..e9361f67 100644 --- a/HISTORY +++ b/HISTORY @@ -1083,3 +1083,6 @@ Video Disk Recorder Revision History - Fixed resetting 'mute' state when setting the volume to a non-zero value. - Added log messages when deleting recordings in case the disk runs full while recording. +- Fixed closing a pipe (used for replaying Dolby Digital audio), which + sometimes left 'zombie' processes behind (thanks to Werner Fink for helping + to debug this one). diff --git a/thread.c b/thread.c index 94ba8605..f4213e43 100644 --- a/thread.c +++ b/thread.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.c 1.18 2002/02/23 13:49:06 kls Exp $ + * $Id: thread.c 1.19 2002/03/09 11:51:56 kls Exp $ */ #include "thread.h" @@ -327,14 +327,21 @@ int cPipe::Close(void) f = NULL; } - if (pid >= 0) { + if (pid > 0) { int status = 0; - struct rusage ru; int i = 5; - while (ret == -1 && i > 0) { - usleep(1000); - ret = wait4(pid, &status, WNOHANG, &ru); + while (i > 0) { + ret = waitpid(pid, &status, WNOHANG); + if (ret < 0) { + if (errno != EINTR && errno != ECHILD) { + LOG_ERROR; + break; + } + } + else if (ret == pid) + break; i--; + usleep(100000); } if (!i) {