mirror of
https://github.com/Genymobile/scrcpy
synced 2025-01-03 05:02:07 +00:00
Force server exit at the end of main()
By default, the Java process exits when all non-daemon threads are terminated. The Android SDK might start some non-daemon threads internally, preventing the scrcpy server to exit in some cases. So force the process to exit explicitly. PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
This commit is contained in:
parent
23e116064d
commit
41ccb5883e
@ -170,7 +170,22 @@ public final class Server {
|
|||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) {
|
||||||
|
int status = 0;
|
||||||
|
try {
|
||||||
|
internalMain(args);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
status = 1;
|
||||||
|
} finally {
|
||||||
|
// By default, the Java process exits when all non-daemon threads are terminated.
|
||||||
|
// The Android SDK might start some non-daemon threads internally, preventing the scrcpy server to exit.
|
||||||
|
// So force the process to exit explicitly.
|
||||||
|
System.exit(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void internalMain(String... args) throws Exception {
|
||||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
|
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
|
||||||
Ln.e("Exception on thread " + t, e);
|
Ln.e("Exception on thread " + t, e);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user