I have a .NET class library that spins up a secondary process which is kept running until I dispose of the object.
Due to some occurances of the program lingering in memory, I've decided to add an integration test to ensure that if I let the object lapse to GC/Finalization, that process is spun down.
However, since the process is the Mercurial command line client, and my build server is already running Mercurial as part of its own operations, I envision situations where Mercurial is either already running when that test starts, or that it is started, and is still running, when the test finishes, in relation to the build server, and not my test.
So, I want to make sure the Mercurial client I find (or not) is the one I started, and not just any client that is currently running.
So the question is this:
- How can I find out if the Mercurial client I am looking at was started by my process?
By "looking at", I was looking at using the Process.GetProcesses method, but this is not a requirement.
If a different question is better, "How to find all child processes of my own process", ie. easier to answer, that one is more than enough as well.
I found this page: How I can know the parent process ID of a process?, but it seems that I have to give it the process name. If I just give it "hg", isn't that question too ambiguous for the case I'm looking for?