[Mono-list] Change mono process name in ps/top

Michael Hutchinson m.j.hutchinson at gmail.com
Sun Jan 24 15:57:36 EST 2010

On Sun, Jan 24, 2010 at 10:55 AM, Robert Jordan <robertj at gmx.net> wrote:
> On 24.01.2010 16:08, Bryan Murphy wrote:
>> On Sat, Jan 23, 2010 at 3:41 PM, Michael Hutchinson<
>> m.j.hutchinson at gmail.com>  wrote:
>>> For setting the name that ps uses you can use the -a argument to exec.
>>> Some older systems may not support this, such as MacOS 10.4, but we do
>>> it in MonoDevelop and haven't seen any problems reported with Linuxes.
>>> exec -a processname mono your.exe
>>> You need to use both tricks to make sure the name shows up everywhere.
>> I tried Robert's suggestion, however, because it doesn't work under ps it's
>> not as useful as I would like it to be.  At the end of the day, I'm trying
>> to accomplish something like what postgres does:
>> ps aux | grep postgres
>> postgres: IDLE
>> postgres: SELECT
>> postgres: INSERT
>> etc.
>> where I can get a quick idea what the process is doing without having to dig
>> around a bunch of log files.  It's clearly possible, other applications do
>> it.
> Yes, native applications with access to main's argv[0] can achieve
> it easily under Linux, but managed apps simply cannot access this
> location. There is also no way that I know of to get a ptr to
> this memory location from a native library, so p/invoke won't
> help either.
> You may want to file an enhancement request with Mono's bugzilla
> stating that you wish a facility for *dynamically* changing
> the process name.

I guess it's *possible* right now with Mono too. Instead of using the
"mono" executable to run the app, create a tiny native app that uses
libmono and the embedding interfaces to load and run the managed exe.
This native shim can capture argv[0] and expose it via a P/Invokeable

Michael Hutchinson

More information about the Mono-list mailing list