Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
5e4d2ded
Commit
5e4d2ded
authored
Nov 04, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor log_daemon changes
parent
411ea56a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
log_daemon.cpp
native/jni/daemon/log_daemon.cpp
+9
-8
daemon.h
native/jni/include/daemon.h
+2
-2
No files found.
native/jni/daemon/log_daemon.cpp
View file @
5e4d2ded
...
...
@@ -18,7 +18,7 @@
#include "daemon.h"
#include "flags.h"
int
log_daemon_started
=
0
;
bool
log_daemon_started
=
false
;
static
Array
<
const
char
*>
log_cmd
,
clear_cmd
;
static
pthread_mutex_t
lock
=
PTHREAD_MUTEX_INITIALIZER
;
...
...
@@ -27,16 +27,18 @@ enum {
LOG_EVENT
};
#define EVENT_NUM 2
struct
log_listener
{
int
fd
;
int
(
*
filter
)
(
const
char
*
);
bool
(
*
filter
)(
const
char
*
);
};
static
int
am_proc_start_filter
(
const
char
*
log
)
{
static
bool
am_proc_start_filter
(
const
char
*
log
)
{
return
strstr
(
log
,
"am_proc_start"
)
!=
nullptr
;
}
static
int
magisk_log_filter
(
const
char
*
log
)
{
static
bool
magisk_log_filter
(
const
char
*
log
)
{
return
!
am_proc_start_filter
(
log
);
}
...
...
@@ -50,7 +52,6 @@ static struct log_listener events[] = {
.
filter
=
magisk_log_filter
}
};
#define EVENT_NUM (sizeof(events) / sizeof(struct log_listener))
static
void
sigpipe_handler
(
int
)
{
close
(
events
[
HIDE_EVENT
].
fd
);
...
...
@@ -126,7 +127,7 @@ static void log_daemon() {
// Construct cmdline
log_cmd
.
push_back
(
MIRRDIR
"/system/bin/logcat"
);
// Test whether these buffers actually works
const
char
*
b
[]
=
{
"main"
,
"events"
,
"crash"
};
const
char
*
b
[]
=
{
"main"
,
"events"
,
"crash"
};
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
exec_command_sync
(
MIRRDIR
"/system/bin/logcat"
,
"-b"
,
b
[
i
],
"-d"
,
"-f"
,
"/dev/null"
,
nullptr
)
==
0
)
{
log_cmd
.
push_back
(
"-b"
);
...
...
@@ -179,12 +180,12 @@ static void log_daemon() {
}
}
int
start_log_daemon
()
{
bool
start_log_daemon
()
{
if
(
!
log_daemon_started
)
{
if
(
exec_command_sync
(
MIRRDIR
"/system/bin/logcat"
,
"-d"
,
"-f"
,
"/dev/null"
,
nullptr
)
==
0
)
{
if
(
fork_dont_care
()
==
0
)
log_daemon
();
log_daemon_started
=
1
;
log_daemon_started
=
true
;
// Wait till we can connect to log_daemon and receive ack
int
fd
=
connect_log_daemon
();
write_int
(
fd
,
HANDSHAKE
);
...
...
native/jni/include/daemon.h
View file @
5e4d2ded
...
...
@@ -43,9 +43,9 @@ int connect_daemon();
// log_monitor.c
extern
int
log_daemon_started
;
extern
bool
log_daemon_started
;
int
connect_log_daemon
();
int
start_log_daemon
();
bool
start_log_daemon
();
// socket.c
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment