Q:

Starting and stopping firefox from c#

When I start 
/Applications/Firefox.app/Contents/MacOS/firefox-bin 
on MacOSX using Process.Start() using Mono, the id of the process that gets returned does not match the process that firefox ends up running under.
It looks like firefox quickly decides to start another process, and kill the current one.
This makes it difficult to stop firefox, and to detect if it is still running.  I've tried starting firefox using the -no-remote flag, to no avail.
Is there a way to start firefox in such a way that it doesn't do this "I'll quickly make a new process for you" dance?
The situation can somewhat be detected by making sure Firefox keeps on running for at least 3 seconds after its start, and when it does not, scan for other firefox processes. However, this technique is shaky at best, as on slow days it might take a bit more than 3 seconds, and then all tests depending on this behaviour fail.
It turns out, that this behaviour only happens when asking firefox to start a specific profile using -P MyProfile.  (Which I need to do, as I need to start firefox with specific proxyserver settings) If I start firefox "normally" it does stick to its process.

A:

When using mozilla programmatically / embedding in other apps you should use the provided components:
"The right way" as recommended by mozilla ...
https://developer.mozilla.org/en/XPCOM
"The easy way", general consensus from Mozilla dev guys ...
http://www.iol.ie/~locka/mozilla/control.htm
Need to "execute processes", simply instantiate an instance of the component and talk to that, you should then have everything you need.
However ...
If you really do insist on looking after the actual process for a firefox instance, you may want to call
Process.Start("...\firefox.exe");
Then try this (i believe this works on MAC OS too) ...
C#/mono: get list of child processes on Windows and Linux
The basic idea / thought pattern being that if it is in fact executing another process right away you should be able to find that as would be a "child" process instead of being just one from a list in the "task list" / process manager for the machine.

