Subject: RE: RE: [DUG]: Process termination
From: "Dennis Chuah" <[email-masked]>
To: Multiple recipients of list delphi <[email-masked]>
Date: Wed, 16 May 2001 14:44:44 +1200

Paul,

> So there is no way to tell (via GetExitCodeProcess) when NT has
> released all the
> resources...

Actually NT is notorious for keeping resources open.  This is especially a
problem if the process opened the resources for read/write.  In that case,
NT usually keeps the resource locked for a few seconds after the process
terminates (to support delayed writing).  There was a M$ knowledge base
article (can't remember the number) that spoke of a set of registry entries
to force NT to close resources, but if you are writing software, I guess you
cannot assume that those entries will be set correctly.

The problem is worse if the resources are on a network.  Sometimes, NT
"forgets" to close the resource all together!

> Wouldn't the same type of thing also occur for the WaitForSingleObject
> WaitForSingleObjectEx ?

The same problem exists for WaitForSingleObject.  The reason I suggest them
is I normally create a thread that calls WaitForSingleObject.  It leaves the
main thread to do other stuff and not having to be bothered with polling
GetExitCodeProcess.

Regards,
Dennis.

> -----Original Message-----
> From: [email-masked] [mailto:[email-masked]]
> Sent: Wednesday, 16 May 2001 14:04
> To: Multiple recipients of list delphi
> Subject: Re:RE: [DUG]: Process termination
>
>
> So there is no way to tell (via GetExitCodeProcess) when NT has
> released all the
> resources...
> Wouldn't the same type of thing also occur for the WaitForSingleObject
> WaitForSingleObjectEx ?
>
> Regards
> Paul McKenzie
>
> =========================
> Paul McKenzie
> Jetbet II Developer
> =========================
> [email-masked]
> Ph: (04) 576-6822
>
> T.A.B. National Office
> 106-110 Jackson Street
> Petone
> New Zealand
>
>
>
> ____________________Reply Separator____________________
> Subject:  RE: [DUG]:  Process termination
> Author:   [email-masked]
> Date:          16/05/2001 13:50
>
>
>
>
>      A success from GetExitCodeProcess does not always guarantee
> that NT is done
>      with the process' resources.  For example, NT may still keep
> the EXE file
>      locked for a short while.
>
>      BTW, a better function to use is WaitForSingleObject /
>      WaitForSingleObjectEx.  Pass in the process handle.  The object is
>      signalled
>      when the process is terminated.
>
>      Regards,
>      Dennis.
>
>      > -----Original Message-----
>      > From: [email-masked]
[mailto:[email-masked]]
     > Sent: Wednesday, 16 May 2001 11:27
     > To: Multiple recipients of list delphi
     > Subject: [DUG]: Process termination
     >
     >
     > Hi All
     >
     > When a Process is terminating and you are waiting for the process
     > to complete
     > its Termination, i.e. waiting on GetExitCodeProcess <> STILL_ACTIVE.
     > Does anyone know if there is a temporary state ("error code")
returned by
     > GetExitCodeProcess, between STILL_ACTIVE and the Process Termination
     fully
     > Completed.
     > Something like "Terminating" ???
     >
     > What we are doing is running the process, waiting for it to
     > terminate, and then
     > closing the handles for the Thread and Process, and deleting the EXE.
     > Every now and then the close handle fails (The GetExitCodeProcess
     > succeeds) and
     > the delete fails.
     >
     > any help much appreciated...
     >
     >
     > Regards
     > Paul McKenzie
     >
     > =========================
     > Paul McKenzie
     > Jetbet II Developer
     > =========================
     > [email-masked]
     > Ph: (04) 576-6822
     >
     > T.A.B. National Office
     > 106-110 Jackson Street
     > Petone
     > New Zealand
     >
     >
     >
     > ------------------------------------------------------------------
     > ---------
     >     New Zealand Delphi Users group - Delphi List -
[email-masked]
     >                   Website: http://www.delphi.org.nz
     > To UnSub, send email to: [email-masked]
     > with body of "unsubscribe delphi"

     -----------------------------------------------------------------------
----
         New Zealand Delphi Users group - Delphi List - [email-masked]
                       Website: http://www.delphi.org.nz
     To UnSub, send email to: [email-masked]
     with body of "unsubscribe delphi"(See attached file: att1.eml)

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [email-masked]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [email-masked] 
with body of "unsubscribe delphi"