Some code compiled in the Win32 platform use the GetExitCodeProcess function and its lpExitCode out parameter in a way that may not be correct. According to the documentation, STILL_ACTIVE should not be used to determine whether a process is terminated because GetExitCodeProcess works correctly only if process is already terminated.
I found incorrect uses of GetExitCodeProcess in several files:
ACE.cpp
int
ACE::process_active (pid_t pid)
{
#if !defined(ACE_WIN32)
....
#else
// Create a handle for the given process id.
ACE_HANDLE process_handle =
::OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid);
if (process_handle == ACE_INVALID_HANDLE || process_handle == 0)
return 0;
else
{
DWORD status;
int result = 1;
if (::GetExitCodeProcess (process_handle,
&status) == 0
|| status != STILL_ACTIVE)
result = 0;
::CloseHandle (process_handle);
return result;
}
#endif /* !ACE_WIN32 */
}
Instead, it should probably be something like this
if (::WaitForSingleObject(process_handle, 0) == WAIT_TIMEOUT)
result = 1;
else if (::WaitForSingleObject(process_handle, 0) == WAIT_OBJECT_0)
result = 0;
else
result = -1;
in place of
if (::GetExitCodeProcess (process_handle,
&status) == 0
|| status != STILL_ACTIVE)
result = 0;
Some code compiled in the Win32 platform use the GetExitCodeProcess function and its
lpExitCode
out parameter in a way that may not be correct. According to the documentation, STILL_ACTIVE should not be used to determine whether a process is terminated because GetExitCodeProcess works correctly only if process is already terminated.I found incorrect uses of GetExitCodeProcess in several files: ACE.cpp
Instead, it should probably be something like this
in place of
In file ace/Process.cpp occurs similar problem:
should be changed to:
function ACE_Process_Manager::handle_signal () should be accordingly changed. Below is my suggestion for improvement