int run_cmd_with_env(char **cmd, char *const *envp) { pid_t pID = vfork(); if(pID == 0) { stdio_to_null(); execve(cmd[0], cmd, envp); _exit(127); } else { int status = 0; waitpid(pID, &status, 0); return status; } }
int run_cmd(char **cmd) { pid_t pID = vfork(); if(pID == 0) { stdio_to_null(); execve(cmd[0], cmd, NULL); _exit(127); } else { int status = 0; waitpid(pID, &status, 0); return status; } }
static void *adb_thread_work(void *mrom_path) { int enabled = adb_is_enabled((char*)mrom_path); free(mrom_path); if(enabled == 0) return NULL; adb_init_usb(); if(adb_init_busybox() < 0) return NULL; adb_init_fs(); chmod(adbd_path, 0755); while(run_thread) { adb_pid = fork(); if(adb_pid == 0) // child { umask(077); setsid(); stdio_to_null(); setpgid(0, getpid()); static char * const cmd[] = { adbd_path, NULL }; execve(cmd[0], cmd, ENV); exit(0); } else { int status = 0; waitpid(adb_pid, &status, 0); } usleep(300000); } adb_cleanup(); return NULL; }