Commit b2431b98 authored by topjohnwu's avatar topjohnwu

Prettify code

parent 8d6d619e
......@@ -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
......@@ -275,7 +282,4 @@ int main(int argc, char **argv, char **envp) {
fclose(logfile);
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