Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Conversation

Zitrax
Copy link
Contributor

@Zitrax Zitrax commented Feb 1, 2013

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.

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.

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.
@Zitrax
Copy link
Contributor Author

Zitrax commented Feb 1, 2013

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.

@Zitrax
Copy link
Contributor Author

Zitrax commented Feb 4, 2013

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 {
Copy link
Member

Choose a reason for hiding this comment

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

Should use a vararg

@andreastt
Copy link
Member

Rebased and fixed up the patch, signed off, and commited: b0c2b26

@andreastt andreastt closed this Apr 2, 2013
pattern.append("\"?");
for (String arg : cmdarray) {
for (int i = 1; i < cmdarray.length; i++) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

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.

3 participants