Skip to content

Use Job objects in lieu of a shutdown hook on Windows.#133

Open
doctorpangloss wants to merge 3 commits into
brettwooldridge:masterfrom
doctorpangloss:master
Open

Use Job objects in lieu of a shutdown hook on Windows.#133
doctorpangloss wants to merge 3 commits into
brettwooldridge:masterfrom
doctorpangloss:master

Conversation

@doctorpangloss
Copy link
Copy Markdown

Shutdown hooks have bad behavior on Windows. Using Windows Job objects
ensure child processes die when the parent process (the NuProcess
caller) dies, regardless of the circumstances that caused the JVM
running NuProcess died.

Shutdown hooks have bad behavior on Windows. Using Windows Job objects
ensure child processes die when the parent process (the NuProcess
caller) dies, regardless of the circumstances that caused the JVM
running NuProcess died.
}

if (!AssignProcessToJobObject(hJob, getPidHandle())) {
throw new RuntimeException("Failed to attach to job " + Native.getLastError());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're almost certainly going to leak a process if this happens. start will catch this exception and (from my own changes) log it, and then return without the process ever being terminated.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should I do?

@@ -226,6 +222,8 @@ public void setProcessHandler(NuProcessHandler processHandler)

NuProcess start(List<String> commands, String[] environment, Path cwd)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you also make changes to run below so it uses jobs too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants