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