Commit e373e596 authored by topjohnwu's avatar topjohnwu

Make sure file descriptors are setup properly

parent 34bb1844
...@@ -100,6 +100,18 @@ static void *request_handler(void *args) { ...@@ -100,6 +100,18 @@ static void *request_handler(void *args) {
static void main_daemon() { static void main_daemon() {
android_logging(); android_logging();
int fd = xopen("/dev/null", O_WRONLY);
xdup2(fd, STDOUT_FILENO);
xdup2(fd, STDERR_FILENO);
if (fd > STDERR_FILENO)
close(fd);
fd = xopen("/dev/zero", O_RDONLY);
xdup2(fd, STDIN_FILENO);
if (fd > STDERR_FILENO)
close(fd);
close(fd);
setsid(); setsid();
setcon("u:r:" SEPOL_PROC_DOMAIN ":s0"); setcon("u:r:" SEPOL_PROC_DOMAIN ":s0");
restore_rootcon(); restore_rootcon();
...@@ -112,14 +124,6 @@ static void main_daemon() { ...@@ -112,14 +124,6 @@ static void main_daemon() {
}, true); }, true);
} }
int fd = xopen("/dev/null", O_RDWR | O_CLOEXEC);
xdup2(fd, STDOUT_FILENO);
xdup2(fd, STDERR_FILENO);
close(fd);
fd = xopen("/dev/zero", O_RDWR | O_CLOEXEC);
xdup2(fd, STDIN_FILENO);
close(fd);
LOGI(SHOW_VER(Magisk) " daemon started\n"); LOGI(SHOW_VER(Magisk) " daemon started\n");
// Get server stat // Get server stat
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment