Skip to content

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

Closed
wants to merge 2 commits into from

2 participants

@ptarabbia

Hi,

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

Regards,

Patrice

@ptarabbia ptarabbia 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.
c59f886
@aleks-f aleks-f was assigned May 1, 2013
@aleks-f
POCO C++ Libraries 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 would work too, though in my opinion, it makes sense, semantically, if kill() modifies the ProcessHandle.

@aleks-f
POCO C++ Libraries 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
Something went wrong with that request. Please try again.