Keep track of the lifetime of a child process in C#
<p>Part of our job is interfacing with an ERP system. Some of the processes within that system can be automated by calling a specific exe called IMPAUT.exe in the base directory of the ERP system. I pass the ERP sub program ID to IMPAUT and it fires off.</p>

<p>Now, what IMPAUT does is determines if the ERP installation is a client or standalone installation, and then IMPAUT fires off a child process. This child process is either IMPACT.exe or IMPCSC.exe. Once IMPAUT has fired off the child process, IMPAUT dies. The child process continues to live for a while. The child process only dies when it has completed the command and has logged out of the ERP system.</p>

<p>The problem is, that while the child process is still alive, I can't call IMPAUT again, because only one instance of the child program may be logged in to the ERP system. I also can't monitor when IMPAUT dies, because the child process will still be alive long after IMPAUT has died.</p>

<p>I need to determine when the child process has died for the specific IMPAUT process that invoked it. So from the parent, I need to get the child process it invokes, before the parent process has died and monitor that child process' lifetime.</p>
