Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!sdd.hp.com!hplabs!otter.hpl.hp.com!otter!hdg From: hdg@otter.hpl.hp.com (Hugh Duggan) Newsgroups: comp.os.os2.misc Subject: Re: knowing when a child process has died Message-ID: <44610004@otter.hpl.hp.com> Date: 21 Feb 91 09:40:38 GMT References: <15458@uswat.UUCP> Organization: Hewlett-Packard Laboratories, Bristol, UK. Lines: 41 > I need to know how to determine when a particular child process has > died - at any given time in my program. > > ... > > Ilene > ---------- You could create a thread which would block on a DosCWait() call. This could then change some global data (protected by semaphore), or post a message on a queue to inform the main thread. I do something very close to this in some code that I am developing, and it works very well. The thread procedure looks something like this: VOID FAR CrashDetectThread() { while ( TRUE ) { RESULTCODES rc; PID pidEnded; DosCwait( DCWA_PROCESS, DCWW_WAIT, &rc, &pidEnded, 0 ); // Once I have got to here, a child process has died. if ( rc.codeTerminate != TC_EXIT ) { // ---------------- A child has died abnormally ------------- // Do stuff } } } I hope this helps, Hugh Duggan, HP Labs, Bristol