简体   繁体   中英

How to check if process is still running on Windows server 2008?

We have two services: one service is 32-bit (process1) and the other is 64-bit (process2). We have code that process1 is using to check if process2 is running: HANDLE hProcess; RESET_WIN_ERRNO;

hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ProcessId);
if (hProcess == NULL) {
    os_SetWinErr(err_code);
    return FALSE;
} 
CloseHandle(hProcess);
return TRUE;

This code works fine in Windows server 2003 but doesn't work in Windows server 2008. Any ideas?

I read about Session0 for services that was introduced in win2008 but in our case both are services (unless Microsoft hates java so much that moves it to Session1), so there shouldn't be any access problems.

I found this thread: http://social.msdn.microsoft.com/forums/en-US/winserver2008appcompatabilityandcertification/thread/c7d7e3fe-f8e5-49c3-a16f-8e3dec5e8cf8/ which states that 32-bit process cannot access 64-bit process anymore. What can be done here?

may be, this is because 32bit process handle is 4bytes(sizeof pointer), 64bit process handle is 8bytes(sizeof pointer?)? if yes, 32bit process handle may not hold 64bit process handle.

http://social.msdn.microsoft.com/Forums/en-US/wlsearchdev/thread/9282b719-fc63-482f-bf42-398e8f03238a hope this helps

Write a 64-bit helper program that will do the check using that old code and return the result as an exit code. Run this program with CreateProcess() from your 32-bit program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM