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

Robert Jordan robertj at gmx.net
Sun Jan 24 18:20:36 EST 2010

On 24.01.2010 21:57, Michael Hutchinson wrote:

>> 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
> function.

Well, most people are moving towards managed languages because they
are already sick of C :)

Anyway, here is what's possible, modulo bugs due to the aforementioned
C sickness. The tricky part was how to expand argv[0].
Build instructions are on top of the C file.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mymono.c
Type: text/x-csrc
Size: 1349 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20100125/62825e49/attachment.bin 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.cs
Url: http://lists.ximian.com/pipermail/mono-list/attachments/20100125/62825e49/attachment.pl 

More information about the Mono-list mailing list