-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
WindowsUtils.kill() fix #10
Conversation
On Windows 8 the kill() function did not correctly locate the process in the list. There were two issues: * The executable name in the regexp was duplicated. This patch changed the iteration over the arguments to not include the executable again. * If the process was started without using .exe in the name kill() could not find it as the regexp did not have the .exe there. This patch adds .exe if not already present as an optional match.
Tried on Windows 7 too, the same issue seem to exist there. The unit test I added fails there without the fix and passes with it. |
Forgot to mention, I have signed the CLA. |
In some cases the process list will not have a binary prefixed with the full path, thus the regexp fails as it alwasy expect a \. This makes the \ optional.
@@ -73,6 +74,19 @@ public void testTaskKill() { | |||
assertFalse("taskkill should be found", "taskkill".equals(WindowsUtils.findTaskKill())); | |||
} | |||
|
|||
private void tryKill(String[] cmd) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use a vararg
Rebased and fixed up the patch, signed off, and commited: b0c2b26 |
pattern.append("\"?"); | ||
for (String arg : cmdarray) { | ||
for (int i = 1; i < cmdarray.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this from a foreach? I can't see it gaining anything here and code styles shouldn't change just for the sake of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason was to iterate from 1 instead of 0, see the commit comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I completely missed that. Thanks. I assumed I was missing something, but I couldn't figure out what.
On Windows 8 the kill() function did not correctly locate
the process in the list. There were two issues:
the iteration over the arguments to not include the executable again.
could not find it as the regexp did not have the .exe there. This patch
adds .exe if not already present as an optional match.
Note, I only tried this on Windows 8 so far so it's quite possible it breaks other versions - and I don't know if this is the right approach at all. Creating this for request for comments.