Crashlog: Do not try to read from other executables if /dev/null is missing
This commit is contained in:
@@ -50,6 +50,9 @@
|
|||||||
#if !defined(WITHOUT_DBG_LLDB)
|
#if !defined(WITHOUT_DBG_LLDB)
|
||||||
static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, const char *last)
|
static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, const char *last)
|
||||||
{
|
{
|
||||||
|
int null_fd = open("/dev/null", O_RDWR);
|
||||||
|
if (null_fd == -1) return false;
|
||||||
|
|
||||||
int pipefd[2];
|
int pipefd[2];
|
||||||
if (pipe(pipefd) == -1) return false;
|
if (pipe(pipefd) == -1) return false;
|
||||||
|
|
||||||
@@ -62,11 +65,9 @@ static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, c
|
|||||||
close(pipefd[0]); /* Close unused read end */
|
close(pipefd[0]); /* Close unused read end */
|
||||||
dup2(pipefd[1], STDOUT_FILENO);
|
dup2(pipefd[1], STDOUT_FILENO);
|
||||||
close(pipefd[1]);
|
close(pipefd[1]);
|
||||||
int null_fd = open("/dev/null", O_RDWR);
|
|
||||||
if (null_fd != -1) {
|
|
||||||
dup2(null_fd, STDERR_FILENO);
|
dup2(null_fd, STDERR_FILENO);
|
||||||
dup2(null_fd, STDIN_FILENO);
|
dup2(null_fd, STDIN_FILENO);
|
||||||
}
|
close(null_fd);
|
||||||
|
|
||||||
execvp(file, args);
|
execvp(file, args);
|
||||||
exit(42);
|
exit(42);
|
||||||
@@ -74,6 +75,7 @@ static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, c
|
|||||||
|
|
||||||
/* parent */
|
/* parent */
|
||||||
|
|
||||||
|
close(null_fd);
|
||||||
close(pipefd[1]); /* Close unused write end */
|
close(pipefd[1]); /* Close unused write end */
|
||||||
|
|
||||||
while (buffer < last) {
|
while (buffer < last) {
|
||||||
|
@@ -74,6 +74,9 @@ static void LogStacktraceSigSegvHandler(int sig)
|
|||||||
|
|
||||||
static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, const char *last)
|
static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, const char *last)
|
||||||
{
|
{
|
||||||
|
int null_fd = open("/dev/null", O_RDWR);
|
||||||
|
if (null_fd == -1) return false;
|
||||||
|
|
||||||
int pipefd[2];
|
int pipefd[2];
|
||||||
if (pipe(pipefd) == -1) return false;
|
if (pipe(pipefd) == -1) return false;
|
||||||
|
|
||||||
@@ -86,11 +89,9 @@ static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, c
|
|||||||
close(pipefd[0]); /* Close unused read end */
|
close(pipefd[0]); /* Close unused read end */
|
||||||
dup2(pipefd[1], STDOUT_FILENO);
|
dup2(pipefd[1], STDOUT_FILENO);
|
||||||
close(pipefd[1]);
|
close(pipefd[1]);
|
||||||
int null_fd = open("/dev/null", O_RDWR);
|
|
||||||
if (null_fd != -1) {
|
|
||||||
dup2(null_fd, STDERR_FILENO);
|
dup2(null_fd, STDERR_FILENO);
|
||||||
dup2(null_fd, STDIN_FILENO);
|
dup2(null_fd, STDIN_FILENO);
|
||||||
}
|
close(null_fd);
|
||||||
|
|
||||||
execvp(file, args);
|
execvp(file, args);
|
||||||
exit(42);
|
exit(42);
|
||||||
@@ -98,6 +99,7 @@ static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, c
|
|||||||
|
|
||||||
/* parent */
|
/* parent */
|
||||||
|
|
||||||
|
close(null_fd);
|
||||||
close(pipefd[1]); /* Close unused write end */
|
close(pipefd[1]); /* Close unused write end */
|
||||||
|
|
||||||
while (buffer < last) {
|
while (buffer < last) {
|
||||||
|
Reference in New Issue
Block a user