• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

WaitForSingleObject(hProcess, ... does not work under WinXP if user is not Administrator

I have an WinXP specific problem described in C++ code bellow:

The XP does not notify the WaitForSigleObject(hProcess...) function when the process is gone.

If the current logged WinXP user is Administrator everything work Ok. If the OS is Win2K or earlier everything works Ok even the user is not an Administrator (just a Restricted user).

TCHAR szCommand = _T("\\Public\\MyProcess.exe");
TCHAR szPath[] = _T("\\Public");
STARTUPINFO si;
PROCESS_INFORMATION procInfo;

ZeroMemory(&si,sizeof(STARTUPINFO));
ZeroMemory(&procInfo, sizeof(PROCESS_INFORMATION));
si.cb = sizeof(STARTUPINFO);

BOOL b = CreateProcess(NULL, szCommand, NULL, NULL, FALSE, 0, 0, szPath, &si, &procInfo);

if(b)
{
     //never returns, even if the process is gone, if the user does not
        //have Administrator right, under XP only
     result = WaitForSingleObject(procInfo.hProcess, INFINITE);

}
0
Marius_Samoila
Asked:
Marius_Samoila
1 Solution
 
AlexFMCommented:
I tested this on WinXP Professional Edition, with Notepad process and non-Administrator account. WaitForSingleObject returns as expected.
Maybe your process doesn't exit in such account. Check this in Task Manager.
0
 
Marius_SamoilaAuthor Commented:
I tested with Notepad and it works Ok. Now I realize that the .EXE was the problem: it is java.exe

The process was started like this:

java -jar "Public\MyProgram.jar" -Xms4000 -Xmx-10000

When the user closes the Java application by closing its main window, the window is gone but the porcess is not. I can see java.exe in TaskManager.

But if the user has administrator rights, everithing is Ok: java.exe is also gone when the window is closed.

WaitForSingleObject works properly: the process is still there.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now