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
6072744f
Commit
6072744f
authored
Jul 15, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent logcat monitors crashing
parent
a87ad35a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
7 deletions
+14
-7
bootstages.c
jni/daemon/bootstages.c
+1
-1
log_monitor.c
jni/daemon/log_monitor.c
+4
-1
proc_monitor.c
jni/magiskhide/proc_monitor.c
+4
-2
misc.c
jni/utils/misc.c
+5
-3
No files found.
jni/daemon/bootstages.c
View file @
6072744f
...
@@ -489,6 +489,7 @@ void post_fs_data(int client) {
...
@@ -489,6 +489,7 @@ void post_fs_data(int client) {
debug_log_fd
=
xopen
(
DEBUG_LOG
,
O_WRONLY
|
O_CREAT
|
O_CLOEXEC
|
O_TRUNC
,
0644
);
debug_log_fd
=
xopen
(
DEBUG_LOG
,
O_WRONLY
|
O_CREAT
|
O_CLOEXEC
|
O_TRUNC
,
0644
);
char
*
const
command
[]
=
{
"logcat"
,
"-v"
,
"brief"
,
NULL
};
char
*
const
command
[]
=
{
"logcat"
,
"-v"
,
"brief"
,
NULL
};
debug_log_pid
=
run_command
(
0
,
&
debug_log_fd
,
"/system/bin/logcat"
,
command
);
debug_log_pid
=
run_command
(
0
,
&
debug_log_fd
,
"/system/bin/logcat"
,
command
);
close
(
debug_log_fd
);
#endif
#endif
LOGI
(
"** post-fs-data mode running
\n
"
);
LOGI
(
"** post-fs-data mode running
\n
"
);
...
@@ -776,6 +777,5 @@ void late_start(int client) {
...
@@ -776,6 +777,5 @@ void late_start(int client) {
// Stop recording the boot logcat after every boot task is done
// Stop recording the boot logcat after every boot task is done
kill
(
debug_log_pid
,
SIGTERM
);
kill
(
debug_log_pid
,
SIGTERM
);
waitpid
(
debug_log_pid
,
NULL
,
0
);
waitpid
(
debug_log_pid
,
NULL
,
0
);
close
(
debug_log_fd
);
#endif
#endif
}
}
jni/daemon/log_monitor.c
View file @
6072744f
...
@@ -31,7 +31,10 @@ static void *logger_thread(void *args) {
...
@@ -31,7 +31,10 @@ static void *logger_thread(void *args) {
if
(
log_pid
>
0
)
if
(
log_pid
>
0
)
waitpid
(
log_pid
,
NULL
,
0
);
waitpid
(
log_pid
,
NULL
,
0
);
// For some reason it went here, clear buffer and restart
// For some reason it went here, clear buffer and restart
system
(
"logcat -c"
);
char
*
const
restart
[]
=
{
"logcat"
,
"-c"
,
NULL
};
log_pid
=
run_command
(
0
,
NULL
,
"/system/bin/logcat"
,
restart
);
if
(
log_pid
>
0
)
waitpid
(
log_pid
,
NULL
,
0
);
}
}
// Should never be here, but well...
// Should never be here, but well...
...
...
jni/magiskhide/proc_monitor.c
View file @
6072744f
...
@@ -180,7 +180,10 @@ void proc_monitor() {
...
@@ -180,7 +180,10 @@ void proc_monitor() {
while
(
1
)
{
while
(
1
)
{
// Clear previous logcat buffer
// Clear previous logcat buffer
system
(
"logcat -b events -c"
);
char
*
const
restart
[]
=
{
"logcat"
,
"-b"
,
"events"
,
"-c"
,
NULL
};
log_pid
=
run_command
(
0
,
NULL
,
"/system/bin/logcat"
,
restart
);
if
(
log_pid
>
0
)
waitpid
(
log_pid
,
NULL
,
0
);
// Monitor am_proc_start
// Monitor am_proc_start
char
*
const
command
[]
=
{
"logcat"
,
"-b"
,
"events"
,
"-v"
,
"raw"
,
"-s"
,
"am_proc_start"
,
NULL
};
char
*
const
command
[]
=
{
"logcat"
,
"-b"
,
"events"
,
"-v"
,
"raw"
,
"-s"
,
"am_proc_start"
,
NULL
};
...
@@ -269,6 +272,5 @@ void proc_monitor() {
...
@@ -269,6 +272,5 @@ void proc_monitor() {
kill
(
log_pid
,
SIGTERM
);
kill
(
log_pid
,
SIGTERM
);
waitpid
(
log_pid
,
NULL
,
0
);
waitpid
(
log_pid
,
NULL
,
0
);
close
(
log_fd
);
close
(
log_fd
);
log_pid
=
0
;
}
}
}
}
jni/utils/misc.c
View file @
6072744f
...
@@ -232,8 +232,6 @@ int run_command(int err, int *fd, const char *path, char *const argv[]) {
...
@@ -232,8 +232,6 @@ int run_command(int err, int *fd, const char *path, char *const argv[]) {
if
(
xpipe2
(
pipefd
,
O_CLOEXEC
)
==
-
1
)
if
(
xpipe2
(
pipefd
,
O_CLOEXEC
)
==
-
1
)
return
-
1
;
return
-
1
;
writeEnd
=
pipefd
[
1
];
writeEnd
=
pipefd
[
1
];
// Give the read end of the pipe
*
fd
=
pipefd
[
0
];
}
else
{
}
else
{
writeEnd
=
*
fd
;
writeEnd
=
*
fd
;
}
}
...
@@ -241,7 +239,11 @@ int run_command(int err, int *fd, const char *path, char *const argv[]) {
...
@@ -241,7 +239,11 @@ int run_command(int err, int *fd, const char *path, char *const argv[]) {
int
pid
=
fork
();
int
pid
=
fork
();
if
(
pid
!=
0
)
{
if
(
pid
!=
0
)
{
close
(
writeEnd
);
if
(
fd
&&
*
fd
<
0
)
{
// Give the read end and close write end
*
fd
=
pipefd
[
0
];
close
(
pipefd
[
1
]);
}
return
pid
;
return
pid
;
}
}
...
...
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