Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe523c67 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Wrap logcat invocations with timeout.

We've seen evidence that the logcat binary can end up wedged, which
means we can eventually starve system_server for FDs.  To mitigate
this, wrap logcat using the timeout utility to kill and clean up if
it takes too long to exit.

Bug: 27994717, 28021719, 28009200
Change-Id: Ieed1460d89598628a5db868645fd305d0e9054ed
parent 12a52bc3
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -13227,10 +13227,11 @@ public final class ActivityManagerService extends ActivityManagerNative
                    // Merge several logcat streams, and take the last N lines
                    InputStreamReader input = null;
                    try {
                        java.lang.Process logcat = new ProcessBuilder("/system/bin/logcat",
                                "-v", "time", "-b", "events", "-b", "system", "-b", "main",
                                "-b", "crash",
                                "-t", String.valueOf(lines)).redirectErrorStream(true).start();
                        java.lang.Process logcat = new ProcessBuilder(
                                "/system/bin/timeout", "-k", "15s", "10s",
                                "/system/bin/logcat", "-v", "time", "-b", "events", "-b", "system",
                                "-b", "main", "-b", "crash", "-t", String.valueOf(lines))
                                        .redirectErrorStream(true).start();
                        try { logcat.getOutputStream().close(); } catch (IOException e) {}
                        try { logcat.getErrorStream().close(); } catch (IOException e) {}