src/native/addrbook/msoutlook/com/server/Server.cxx
/**
 * Wait that the parent process stops.
 */
Wait that the parent process stops.
Wait that the parent process stops .
void waitParentProcessStop()
{
	MsOutlookUtils_log("Waits parent process to stop.");
    HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if(handle != INVALID_HANDLE_VALUE)
    {
    	MsOutlookUtils_log("Valid handle is found.");
        PROCESSENTRY32 processEntry;
        memset(&processEntry, 0, sizeof(processEntry));
        processEntry.dwSize = sizeof(PROCESSENTRY32);
        DWORD id = GetCurrentProcessId();
        if(Process32First(handle, &processEntry))
        {
            do
            {
                if(processEntry.th32ProcessID == id)
                {
                    HANDLE parentHandle
                        = OpenProcess(
                                SYNCHRONIZE
                                | PROCESS_QUERY_INFORMATION
                                | PROCESS_VM_READ,
                                FALSE,
                                processEntry.th32ParentProcessID);
                    DWORD exitCode;
                    GetExitCodeProcess(parentHandle, &exitCode);
                    while(exitCode == STILL_ACTIVE)
                    {
                        WaitForSingleObject(parentHandle, INFINITE);
                        GetExitCodeProcess(parentHandle, &exitCode);
                    }
                    MsOutlookUtils_log("Stop waiting.[1]");
                    CloseHandle(parentHandle);
                    return;
                }
            }
            while(Process32Next(handle, &processEntry));
        }
        CloseHandle(handle);
    }
    else
    {
    	MsOutlookUtils_log("Error - not valid handle found.");
    }
    MsOutlookUtils_log("Stop waiting.[2]");
}
void waitParentProcessStop ( ) { MsOutlookUtils_log ( " " ) ; HANDLE handle = CreateToolhelp32Snapshot ( TH32CS_SNAPPROCESS , 0 ) ; if ( handle != INVALID_HANDLE_VALUE ) { MsOutlookUtils_log ( " " ) ; PROCESSENTRY32 processEntry ; memset ( & processEntry , 0 , sizeof ( processEntry ) ) ; processEntry . dwSize = sizeof ( PROCESSENTRY32 ) ; DWORD id = GetCurrentProcessId ( ) ; if ( Process32First ( handle , & processEntry ) ) { do { if ( processEntry . th32ProcessID == id ) { HANDLE parentHandle = OpenProcess ( SYNCHRONIZE | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ , FALSE , processEntry . th32ParentProcessID ) ; DWORD exitCode ; GetExitCodeProcess ( parentHandle , & exitCode ) ; while ( exitCode == STILL_ACTIVE ) { WaitForSingleObject ( parentHandle , INFINITE ) ; GetExitCodeProcess ( parentHandle , & exitCode ) ; } MsOutlookUtils_log ( " " ) ; CloseHandle ( parentHandle ) ; return ; } } while ( Process32Next ( handle , & processEntry ) ) ; } CloseHandle ( handle ) ; } else { MsOutlookUtils_log ( " " ) ; } MsOutlookUtils_log ( " " ) ; }
Wait that the parent process stops.
Wait that the parent process stops .
// We have found this process // Get the parent process handle. // Wait for our parent to stop.