Prettify code

This commit is contained in:
topjohnwu 2016-12-11 05:10:48 +08:00
parent 8d6d619eed
commit b2431b982f

View File

@ -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) {
fclose(logfile); fclose(logfile);
return 1; return 1;
}
return 0;
} }