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

Posted on 2003-03-25
Medium Priority
Last Modified: 2012-08-13
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");

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

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

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

Question by:Marius_Samoila
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 48

Accepted Solution

AlexFM earned 500 total points
ID: 8208837
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.

Author Comment

ID: 8212411
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.


Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question