Re: problem with WaitForSingleObject on WM5

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Michael/Bruce,
I am sure that child process is exiting, I also tried without
ExitThread/ExitProcess, by simply just returing the main WinMain
thread. But the result is same. The parent waitForSingleObject is not
signaled after child exit and it wait for long until new child create.

BTW is there other way for parent process to know about child exit ?

regards,
Riju

Bruce Eitman [eMVP] wrote:
ExitThread is not the way to have a thread shut down. This has been covered
several times in these newsgroups. You are much better off just returning
from the thread function. ExitThread does not give the thread a chance to
clean up after itself.

--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net

Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member

<rijumreghunath@xxxxxxxxxxxxxx> wrote in message
news:1161008448.534701.200820@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,
I have a problem with WaitForSingleObject on Windows mobile 5.

I have a parent process in which I am creating child processes using
CreateProcess and I remember the child handle in the parent.
CreateProcess(programName, command, NULL, NULL, FALSE, 0, NULL, NULL,
&startupInfo, &processInfo);

I want to wait for child process shutdown, to make sure that all
resources are completely freed by the child. So before the child
process exit (ExitThread()), I am calling
WaitForSingleObject(childProcessHandle, INFINITE) on the parent
process. But interestingly I saw the WaitForSingleObject() hangs when
a child process exits. The hanged WaitForSingleObject() is seen to be
signaled I if launch a new child process from the parents (seems like a
timing issue).

Below is the code that I am using in parent process

DWORD result=0;
HANDLE handle;
handle = OpenProcess(SYNCHRONIZE, FALSE, contextID);
result = WaitForSingleObject(handle, INFINITE);
CloseHandle(handle);

The same piece of code is working finely with WM 2003 and WM 2003 SE.
Please let me know the reason for this platform difference. Also please
let me know if there is any other way to achieve my requirement.

Thanks,
Riju Reghunath


.



Relevant Pages

  • Re: forking in c
    ... the very last child it prints out says it has a parent id ... each child process should have a child process of their own. ... The next statement the child executes is ...
    (comp.unix.programmer)
  • Re: Basic Inter process communication question
    ... I have some general questions about UNIX/Solaris IPC. ... child process and the wait for the child process to complete. ... The twist is that I don¹t want the memory of the parent process to be ...
    (comp.unix.programmer)
  • Re: Blocking system calls, and pthreads
    ... > Maybe it's just easier than forking and having a child process ... > that has all heap allocations and open files from the parent, ... > be used by the child. ...
    (comp.unix.programmer)
  • Re: anonymous pipes
    ... redirecting input and output of the child process i have to use two ... parent say's "hello child" then child should respond "hello ... multiple times and then child should respond multiple times) ...
    (microsoft.public.vc.mfc)
  • Making existing process efficient
    ... output streams and keeps writing records to the ... internal buffer. ... pipe with the child. ... buffer and fork a child process C1. ...
    (comp.unix.programmer)