mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 12:05:30 +00:00
Make sure file descriptors are setup properly
This commit is contained in:
parent
34bb18448c
commit
e373e59661
@ -100,6 +100,18 @@ static void *request_handler(void *args) {
|
||||
|
||||
static void main_daemon() {
|
||||
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();
|
||||
setcon("u:r:" SEPOL_PROC_DOMAIN ":s0");
|
||||
restore_rootcon();
|
||||
@ -112,14 +124,6 @@ static void main_daemon() {
|
||||
}, 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");
|
||||
|
||||
// Get server stat
|
||||
|
Loading…
Reference in New Issue
Block a user