Commit b2431b98 authored by topjohnwu's avatar topjohnwu

Prettify code

parent 8d6d619e
...@@ -194,32 +194,39 @@ void *monitor_list(void *path) { ...@@ -194,32 +194,39 @@ void *monitor_list(void *path) {
return NULL; return NULL;
} }
int main(int argc, char **argv, char **envp) { void run_as_daemon() {
switch(fork()) {
pid_t forkpid = fork(); case -1:
exit(-1);
if (forkpid < 0) case 0:
return 1;
if (forkpid == 0) {
if (setsid() < 0) if (setsid() < 0)
return 1; exit(-1);
close(STDIN_FILENO); close(STDIN_FILENO);
close(STDOUT_FILENO); close(STDOUT_FILENO);
close(STDERR_FILENO); close(STDERR_FILENO);
break;
default:
exit(0);
}
}
int main(int argc, char **argv, char **envp) {
run_as_daemon();
logfile = fopen(LOGFILE, "a+"); logfile = fopen(LOGFILE, "a+");
setbuf(logfile, NULL); setbuf(logfile, NULL);
// Fork a child to handle namespace switches and unmounts // Fork a child to handle namespace switches and unmounts
pipe(pipefd); pipe(pipefd);
forkpid = fork(); switch(fork()) {
if (forkpid < 0) case -1:
return 1; exit(-1);
if (forkpid == 0) case 0:
return hideMagisk(); return hideMagisk();
default:
break;
}
close(pipefd[0]); close(pipefd[0]);
// Start a thread to constantly check the hide list // Start a thread to constantly check the hide list
...@@ -275,7 +282,4 @@ int main(int argc, char **argv, char **envp) { ...@@ -275,7 +282,4 @@ int main(int argc, char **argv, char **envp) {
fclose(logfile); fclose(logfile);
return 1; return 1;
}
return 0;
} }
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