mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
Removed syslog calls in child process after fork()
This commit is contained in:
parent
b1418b6bcd
commit
655682b5d2
@ -2559,6 +2559,7 @@ Markus Ehrnsperger <markus.ehrnsperger@googlemail.com>
|
||||
for fixing a possible crash in cDevice::StopSectionHandler()
|
||||
for making using a dummy OSD if no OSD provider is available not be considered an error
|
||||
any more
|
||||
for removing syslog calls in child process after fork()
|
||||
|
||||
Werner Färber <w.faerber@gmx.de>
|
||||
for reporting a bug in handling the cPluginManager::Active() result when pressing
|
||||
|
1
HISTORY
1
HISTORY
@ -9872,3 +9872,4 @@ Video Disk Recorder Revision History
|
||||
- Using a dummy OSD if no OSD provider is available is not considered an error any
|
||||
more (thanks to Markus Ehrnsperger).
|
||||
- Implemented scaling images (thanks to Andreas Baierl).
|
||||
- Removed syslog calls in child process after fork() (thanks to Markus Ehrnsperger).
|
||||
|
22
thread.c
22
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 5.1 2022/11/13 15:25:52 kls Exp $
|
||||
* $Id: thread.c 5.2 2024/01/18 13:01:07 kls Exp $
|
||||
*/
|
||||
|
||||
#include "thread.h"
|
||||
@ -949,11 +949,11 @@ bool cPipe::Open(const char *Command, const char *Mode)
|
||||
int fd[2];
|
||||
|
||||
if (pipe(fd) < 0) {
|
||||
LOG_ERROR;
|
||||
LOG_ERROR_STR(Command);
|
||||
return false;
|
||||
}
|
||||
if ((pid = fork()) < 0) { // fork failed
|
||||
LOG_ERROR;
|
||||
LOG_ERROR_STR(Command);
|
||||
close(fd[0]);
|
||||
close(fd[1]);
|
||||
return false;
|
||||
@ -969,7 +969,7 @@ bool cPipe::Open(const char *Command, const char *Mode)
|
||||
}
|
||||
close(fd[iopipe]);
|
||||
if ((f = fdopen(fd[1 - iopipe], mode)) == NULL) {
|
||||
LOG_ERROR;
|
||||
LOG_ERROR_STR(Command);
|
||||
close(fd[1 - iopipe]);
|
||||
}
|
||||
return f != NULL;
|
||||
@ -982,7 +982,6 @@ bool cPipe::Open(const char *Command, const char *Mode)
|
||||
}
|
||||
close(fd[iopipe]);
|
||||
if (dup2(fd[1 - iopipe], iofd) == -1) { // now redirect
|
||||
LOG_ERROR;
|
||||
close(fd[1 - iopipe]);
|
||||
_exit(-1);
|
||||
}
|
||||
@ -991,7 +990,6 @@ bool cPipe::Open(const char *Command, const char *Mode)
|
||||
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
|
||||
close(i); //close all dup'ed filedescriptors
|
||||
if (execl("/bin/sh", "sh", "-c", Command, NULL) == -1) {
|
||||
LOG_ERROR_STR(Command);
|
||||
close(fd[1 - iopipe]);
|
||||
_exit(-1);
|
||||
}
|
||||
@ -1044,14 +1042,14 @@ int SystemExec(const char *Command, bool Detached)
|
||||
pid_t pid;
|
||||
|
||||
if ((pid = fork()) < 0) { // fork failed
|
||||
LOG_ERROR;
|
||||
LOG_ERROR_STR(Command);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pid > 0) { // parent process
|
||||
int status = 0;
|
||||
if (waitpid(pid, &status, 0) < 0) {
|
||||
LOG_ERROR;
|
||||
LOG_ERROR_STR(Command);
|
||||
return -1;
|
||||
}
|
||||
return status;
|
||||
@ -1064,19 +1062,17 @@ int SystemExec(const char *Command, bool Detached)
|
||||
// Start a new session
|
||||
pid_t sid = setsid();
|
||||
if (sid < 0)
|
||||
LOG_ERROR;
|
||||
_exit(-1);
|
||||
// close STDIN and re-open as /dev/null
|
||||
int devnull = open("/dev/null", O_RDONLY);
|
||||
if (devnull < 0 || dup2(devnull, 0) < 0)
|
||||
LOG_ERROR;
|
||||
_exit(-1);
|
||||
}
|
||||
int MaxPossibleFileDescriptors = getdtablesize();
|
||||
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
|
||||
close(i); //close all dup'ed filedescriptors
|
||||
if (execl("/bin/sh", "sh", "-c", Command, NULL) == -1) {
|
||||
LOG_ERROR_STR(Command);
|
||||
if (execl("/bin/sh", "sh", "-c", Command, NULL) == -1)
|
||||
_exit(-1);
|
||||
}
|
||||
_exit(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user