summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/thread.c b/thread.c
index 7e5b0ea..94ba860 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.16 2001/10/27 13:23:06 kls Exp $
+ * $Id: thread.c 1.18 2002/02/23 13:49:06 kls Exp $
*/
#include "thread.h"
@@ -190,6 +190,32 @@ bool cThread::EmergencyExit(bool Request)
return emergencyExitRequested = true; // yes, it's an assignment, not a comparison!
}
+// --- cMutexLock ------------------------------------------------------------
+
+cMutexLock::cMutexLock(cMutex *Mutex)
+{
+ mutex = NULL;
+ locked = false;
+ Lock(Mutex);
+}
+
+cMutexLock::~cMutexLock()
+{
+ if (mutex && locked)
+ mutex->Unlock();
+}
+
+bool cMutexLock::Lock(cMutex *Mutex)
+{
+ if (Mutex && !mutex) {
+ mutex = Mutex;
+ Mutex->Lock();
+ locked = true;
+ return true;
+ }
+ return false;
+}
+
// --- cThreadLock -----------------------------------------------------------
cThreadLock::cThreadLock(cThread *Thread)
@@ -277,8 +303,11 @@ bool cPipe::Open(const char *Command, const char *Mode)
_exit(-1);
}
else {
- for (int i = STDERR_FILENO + 1; i < fd[1 - iopipe]; i++)
- close(i); //close all dup'ed filedescriptors
+ for (int i = 0; i <= fd[1]; i++) {
+ if (i == STDIN_FILENO || i == STDOUT_FILENO || i == STDERR_FILENO)
+ continue;
+ close(i); // close all dup'ed filedescriptors
+ }
if (execl("/bin/sh", "sh", "-c", Command, NULL) == -1) {
LOG_ERROR_STR(Command);
close(fd[1 - iopipe]);