Don't call CloseHandle() twice on Windows (as it causes crashes, or unex... #166

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
@ptarabbia
Contributor

ptarabbia commented May 1, 2013

Hi,

Here is a fix for a problem I mentioned on the forum.

Regards,

Patrice

Don't call CloseHandle() twice on Windows (as it causes crashes, or u…
…nexpected behavior). This would happen with the following test case:

ProcessHandle handle = Process.launch(...);
handle.kill();
Then as handle gets out of scope, ~ProcessHandle would call CloseHandle() on an already closed handle.

@ghost ghost assigned aleks-f May 1, 2013

@aleks-f

This comment has been minimized.

Show comment
Hide comment
@aleks-f

aleks-f May 1, 2013

Member

Just skimmed over it - wouldn't it be cleaner to make _handle mutable and leave const& arguments intact?

I'm on the road at the moment, but I will take a better look into it before release

Member

aleks-f commented May 1, 2013

Just skimmed over it - wouldn't it be cleaner to make _handle mutable and leave const& arguments intact?

I'm on the road at the moment, but I will take a better look into it before release

@ptarabbia

This comment has been minimized.

Show comment
Hide comment
@ptarabbia

ptarabbia May 1, 2013

Contributor

This would work too, though in my opinion, it makes sense, semantically, if kill() modifies the ProcessHandle.

Contributor

ptarabbia commented May 1, 2013

This would work too, though in my opinion, it makes sense, semantically, if kill() modifies the ProcessHandle.

@aleks-f

This comment has been minimized.

Show comment
Hide comment
@aleks-f

aleks-f May 2, 2013

Member

There was a related bugreport on SF:

https://sourceforge.net/p/poco/bugs/607/
"When severel thread tryies to call join on another one then CloseHandle could be called more then once with the same handle."

Adding it here, it will all be addressed together.

Member

aleks-f commented May 2, 2013

There was a related bugreport on SF:

https://sourceforge.net/p/poco/bugs/607/
"When severel thread tryies to call join on another one then CloseHandle could be called more then once with the same handle."

Adding it here, it will all be addressed together.

@ptarabbia ptarabbia closed this Jun 3, 2013

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