Skip to content

Commit

Permalink
Start cleanup process with setsid()
Browse files Browse the repository at this point in the history
Reimplement c59a3c3 using Os.setsid().

Refs #5613 comment <#5613 (comment)>

Suggested-by: Simon Chan <[email protected]>
  • Loading branch information
rom1v committed Dec 9, 2024
1 parent 28b5bfb commit a9aadc9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/src/main/java/com/genymobile/scrcpy/CleanUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit a9aadc9

Please sign in to comment.