mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Fixed handling detached processes in SystemExec()
This commit is contained in:
parent
3ad941de73
commit
efbb48dbaf
@ -1497,6 +1497,7 @@ Udo Richter <udo_richter@gmx.de>
|
|||||||
up at a particular time
|
up at a particular time
|
||||||
for making the HUP signal force a restart of VDR
|
for making the HUP signal force a restart of VDR
|
||||||
for fixing a race condition with signal handlers at program exit
|
for fixing a race condition with signal handlers at program exit
|
||||||
|
for fixing handling detached processes in SystemExec()
|
||||||
|
|
||||||
Sven Kreiensen <svenk@kammer.uni-hannover.de>
|
Sven Kreiensen <svenk@kammer.uni-hannover.de>
|
||||||
for his help in keeping 'channels.conf.terr' up to date
|
for his help in keeping 'channels.conf.terr' up to date
|
||||||
|
1
HISTORY
1
HISTORY
@ -5251,3 +5251,4 @@ Video Disk Recorder Revision History
|
|||||||
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg).
|
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg).
|
||||||
- Changed the parameter "OSD font" to "Default font" in "Setup/OSD" (suggested
|
- Changed the parameter "OSD font" to "Default font" in "Setup/OSD" (suggested
|
||||||
by Rolf Ahrenberg).
|
by Rolf Ahrenberg).
|
||||||
|
- Fixed handling detached processes in SystemExec() (thanks to Udo Richter).
|
||||||
|
8
thread.c
8
thread.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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"
|
#include "thread.h"
|
||||||
@ -12,6 +12,7 @@
|
|||||||
#include <linux/unistd.h>
|
#include <linux/unistd.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -507,7 +508,7 @@ int SystemExec(const char *Command, bool Detached)
|
|||||||
|
|
||||||
if (pid > 0) { // parent process
|
if (pid > 0) { // parent process
|
||||||
int status = 0;
|
int status = 0;
|
||||||
if (!Detached && waitpid(pid, &status, 0) < 0) {
|
if (waitpid(pid, &status, 0) < 0) {
|
||||||
LOG_ERROR;
|
LOG_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -515,6 +516,9 @@ int SystemExec(const char *Command, bool Detached)
|
|||||||
}
|
}
|
||||||
else { // child process
|
else { // child process
|
||||||
if (Detached) {
|
if (Detached) {
|
||||||
|
// Fork again and let first child die - grandchild stays alive without parent
|
||||||
|
if (fork() > 0)
|
||||||
|
exit(0);
|
||||||
// Start a new session
|
// Start a new session
|
||||||
pid_t sid = setsid();
|
pid_t sid = setsid();
|
||||||
if (sid < 0)
|
if (sid < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user