summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-03-09 11:51:56 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2002-03-09 11:51:56 +0100
commitac5aecb8eb6d6979877dbf9db813eb8d6b1a6ae6 (patch)
treedbea8faa967637fe945fa7cc2a32f9b2d069f1ce /thread.c
parenta9fd732a721336f4cd34eabfd02afde4e9516065 (diff)
downloadvdr-ac5aecb8eb6d6979877dbf9db813eb8d6b1a6ae6.tar.gz
vdr-ac5aecb8eb6d6979877dbf9db813eb8d6b1a6ae6.tar.bz2
Fixed 'zombie' processes when closing a pipe
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c19
1 files changed, 13 insertions, 6 deletions
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) {