News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

WaitForSingleObject signalling prematurely

Started by Sevag.K, November 19, 2006, 05:00:58 AM

Previous topic - Next topic

Sevag.K


I pass it the WaitForSingleObject procedure the hProcess handle of the PROCESS_INFORMATION structure with time of INFINITE

It works for a while, but if the process is running a long time, it prematurely signals process termination while the process is still running!  Is there something else that can trigger a signaled state?


zooba

I don't know off the top of my head, but Raymond Chen did a few posts a while ago about the WaitFor* set of functions. He may have mentioned something in there.

Do you know what return value you get in the premature case? Also, the WaitForSingleObject documentation suggets using MsgWaitForMultipleObjects/Ex if the code uses  windows. Is this a possibility?

Cheers,

Zooba :U

Sevag.K

Thanks.  The code does use GUI so I'll look up MsgWaitForMultipleOjbects and see if that helps.

P1

Quote from: Sevag.K on November 20, 2006, 12:47:02 AMThanks.  The code does use GUI so I'll look up MsgWaitForMultipleOjbects and see if that helps.
I read a C article, that more or less said, don't use single because of deadlock conditions or indefinite timeout condition without an escape for the program.  At least,you can check the message loop for anything you want to do.

Regards,  P1  :8)

Sevag.K

It looks like I require a more complicated checking mechanism.  MsgWaitForMultipleObjects works better than the the single version, but it still exits prematurely if another instance of the parent program launches the same external process.  I thought each process would have a unique handle and this wouldn't be a problem.

If anyone knows of some assembly code sample that extensively covers this topic please let me know.  I did a quick search of Raymond Chen's site but couldn't find anything with "msgwaitfor.."


Relvinian

Something that I thought of that might be causing problems..

How are you defining the handle for WaitForSingleObject to use?  Are you using CreateEvent?  If so, what parameters are you passing?

I use both WaitForSingleObject, WaitForMultipleObjects and MsgWaitForMultipleObjects just fine before and haven't had problems.

If you are using CreateEvent with params, one of the params is the "identifier" and you may have defined a value that is unique for the OS so all process would recognize it.

If you can, post some code of your creating of the HANDLE you are creating and a small section around the WaitFor calls.

Relvinian

Sevag.K

I use CreateProcess and pass the  hProcess field of the PROCESS_INFORMATION structure.