-
-
Notifications
You must be signed in to change notification settings - Fork 211
fix: kill stale wine processes before launch #1195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
e61abec
b106e51
d9dbf7e
ea948b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,12 +37,51 @@ public static void terminateProcess(int pid) { | |
| // Log.d("ProcessHelper", "Process terminated with pid: " + pid); | ||
| } | ||
|
|
||
| public static void killProcess(int pid) { | ||
| Process.sendSignal(pid, SIGKILL); | ||
| } | ||
|
|
||
| public static void terminateAllWineProcesses() { | ||
| for (String process : listRunningWineProcesses()) { | ||
| terminateProcess(Integer.parseInt(process)); | ||
| } | ||
| } | ||
|
|
||
| public static void killAllWineProcesses() { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we already have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thats the whole point, sigterm seems ignored in some cases, so sigkill is more aggressive which it needs to be on anything that remains in this state |
||
| for (String process : listRunningWineProcesses()) { | ||
| killProcess(Integer.parseInt(process)); | ||
| } | ||
|
xXJSONDeruloXx marked this conversation as resolved.
|
||
| } | ||
|
|
||
| public static void hardKillStaleWineProcesses() throws InterruptedException { | ||
| long deadlineMs = System.currentTimeMillis() + 5000; | ||
| List<String> stalePids = listRunningWineProcesses(); | ||
|
|
||
| if (stalePids.isEmpty()) { | ||
| return; | ||
| } | ||
|
|
||
| Log.w("ProcessHelper", String.format( | ||
| "Found %d stale Wine process(es) before launch; hard-killing: %s", | ||
| stalePids.size(), String.join(", ", stalePids))); | ||
|
|
||
| killAllWineProcesses(); | ||
|
|
||
| List<String> remaining; | ||
| do { | ||
| Thread.sleep(100); | ||
| remaining = listRunningWineProcesses(); | ||
| } while (!remaining.isEmpty() && System.currentTimeMillis() < deadlineMs); | ||
|
|
||
| if (!remaining.isEmpty()) { | ||
| Log.w("ProcessHelper", String.format( | ||
| "Wine processes still present after hard-kill: %s", | ||
| String.join(", ", remaining))); | ||
| throw new IllegalStateException( | ||
| "Wine processes still present after hard-kill attempt: " + String.join(", ", remaining)); | ||
| } | ||
| } | ||
|
|
||
| public static void pauseAllWineProcesses() { | ||
| for (String process : listRunningWineProcesses()) { | ||
| suspendProcess(Integer.parseInt(process)); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.