mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-22 14:11:33 +00:00
Add new util function
This commit is contained in:
parent
6785dc4967
commit
23d3e56967
@ -525,7 +525,7 @@ static void dump_logs() {
|
|||||||
rename(LOGFILE, LOGFILE ".bak");
|
rename(LOGFILE, LOGFILE ".bak");
|
||||||
log_dump = true;
|
log_dump = true;
|
||||||
// Start a daemon thread and wait indefinitely
|
// Start a daemon thread and wait indefinitely
|
||||||
new_daemon_thread([](auto) -> void* {
|
new_daemon_thread([]() -> void {
|
||||||
int fd = xopen(LOGFILE, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644);
|
int fd = xopen(LOGFILE, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644);
|
||||||
exec_t exec {
|
exec_t exec {
|
||||||
.fd = fd,
|
.fd = fd,
|
||||||
@ -535,10 +535,9 @@ static void dump_logs() {
|
|||||||
close(fd);
|
close(fd);
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
log_dump = false;
|
log_dump = false;
|
||||||
return nullptr;
|
} else {
|
||||||
}
|
|
||||||
waitpid(pid, nullptr, 0);
|
waitpid(pid, nullptr, 0);
|
||||||
return nullptr;
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,10 +322,7 @@ void auto_start_magiskhide() {
|
|||||||
db_settings dbs;
|
db_settings dbs;
|
||||||
get_db_settings(dbs, HIDE_CONFIG);
|
get_db_settings(dbs, HIDE_CONFIG);
|
||||||
if (dbs[HIDE_CONFIG]) {
|
if (dbs[HIDE_CONFIG]) {
|
||||||
new_daemon_thread([](auto) -> void* {
|
new_daemon_thread([]() -> void { launch_magiskhide(-1); });
|
||||||
launch_magiskhide(-1);
|
|
||||||
return nullptr;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +208,7 @@ int parse_int(S __s) { return parse_int(__s.data()); }
|
|||||||
|
|
||||||
int new_daemon_thread(void *(*start_routine) (void *), void *arg = nullptr,
|
int new_daemon_thread(void *(*start_routine) (void *), void *arg = nullptr,
|
||||||
const pthread_attr_t *attr = nullptr);
|
const pthread_attr_t *attr = nullptr);
|
||||||
|
int new_daemon_thread(std::function<void()> &&fn);
|
||||||
|
|
||||||
struct exec_t {
|
struct exec_t {
|
||||||
bool err = false;
|
bool err = false;
|
||||||
|
@ -200,6 +200,17 @@ int new_daemon_thread(void *(*start_routine) (void *), void *arg, const pthread_
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *proxy_routine(void *fp) {
|
||||||
|
auto fn = reinterpret_cast<std::function<void()>*>(fp);
|
||||||
|
(*fn)();
|
||||||
|
delete fn;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int new_daemon_thread(std::function<void()> &&fn) {
|
||||||
|
return new_daemon_thread(proxy_routine, new std::function<void()>(std::move(fn)));
|
||||||
|
}
|
||||||
|
|
||||||
static char *argv0;
|
static char *argv0;
|
||||||
static size_t name_len;
|
static size_t name_len;
|
||||||
void init_argv0(int argc, char **argv) {
|
void init_argv0(int argc, char **argv) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user