diff --git a/server/src/main/java/com/genymobile/scrcpy/CleanUp.java b/server/src/main/java/com/genymobile/scrcpy/CleanUp.java index f372855bf2..49b23e819a 100644 --- a/server/src/main/java/com/genymobile/scrcpy/CleanUp.java +++ b/server/src/main/java/com/genymobile/scrcpy/CleanUp.java @@ -6,6 +6,8 @@ import com.genymobile.scrcpy.util.SettingsException; import android.os.BatteryManager; +import android.system.ErrnoException; +import android.system.Os; import java.io.File; import java.io.IOException; @@ -163,6 +165,12 @@ public static void unlinkSelf() { } public static void main(String... args) { + try { + // Start a new session to avoid being terminated along with the server process on some devices + Os.setsid(); + } catch (ErrnoException e) { + Ln.e("setsid() failed", e); + } unlinkSelf(); int displayId = Integer.parseInt(args[0]);