summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2007-06-17 12:45:57 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2007-06-17 12:45:57 +0200
commitefbb48dbaf648caccd0a7591558252f8e00f0071 (patch)
treed6ae44924c27bef2ba4f627e2ba9d30dd26eedf7 /thread.c
parent3ad941de73f411f42be4439aaf9e73837915376f (diff)
downloadvdr-efbb48dbaf648caccd0a7591558252f8e00f0071.tar.gz
vdr-efbb48dbaf648caccd0a7591558252f8e00f0071.tar.bz2
Fixed handling detached processes in SystemExec()
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index 8882252a..4eb64f1e 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.60 2007/02/24 16:13:33 kls Exp $
+ * $Id: thread.c 1.61 2007/06/17 12:43:40 kls Exp $
*/
#include "thread.h"
@@ -12,6 +12,7 @@
#include <linux/unistd.h>
#include <malloc.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
@@ -507,7 +508,7 @@ int SystemExec(const char *Command, bool Detached)
if (pid > 0) { // parent process
int status = 0;
- if (!Detached && waitpid(pid, &status, 0) < 0) {
+ if (waitpid(pid, &status, 0) < 0) {
LOG_ERROR;
return -1;
}
@@ -515,6 +516,9 @@ int SystemExec(const char *Command, bool Detached)
}
else { // child process
if (Detached) {
+ // Fork again and let first child die - grandchild stays alive without parent
+ if (fork() > 0)
+ exit(0);
// Start a new session
pid_t sid = setsid();
if (sid < 0)