Solved

WaitForSingleObject returns WAIT_OBJECT_0

Posted on 1998-02-21
3
2,817 Views
Last Modified: 2013-12-03
I'm calling CreateProcess(
   tzAppName,
   NULL,
   NULL,
   NULL,
   FALSE,
   0,
   NULL,
   NULL,
   &StartupInfo,
   &ProcessInfo );

and then

WaitForSingleObject( ProcessInfo.hHandle, INFINITE );

CreateProcess returns TRUE, and WaitForSingleObject
returns WAIT_OBJECT_0. Exectution continues
seemingly without pause. Which is bad, because I'm
waiting for the executable module to exit. Help says
WAIT_OBJECT_0 means "The state of the specified
object is signaled."

The app I'm launching is an internal Setup program, for
what that's worth. Anybody know what gives?
0
Comment
Question by:barrett
3 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 1411448
WAIT_OBJECT_0 means that what you were waiting for happened.  Your process finished.  My guess is that your process in not starting properly.  Use the GetExitCodeProcess function to find out what happened to your process and why it died so quickly.
0
 

Expert Comment

by:flfmdll
ID: 1411449
Your new process is exiting with a signaled state. That's a given I suppose. Perhaps your exit or return value is 1 no matter what for this process. You can look into the code to change it. Something is not working in your new process, returning, and making your WaitForSingleObject think it is okay to continue. It seems your code for spawning it is okay.
0
 

Author Comment

by:barrett
ID: 1411450
As it turns out, the exe I was spawning was just a stub that launched another process. Once I got the name of the other mutex, everything was fine. Thanks for answering...
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

680 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