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

Michael Hutchinson m.j.hutchinson at gmail.com
Sat Jan 23 16:41:18 EST 2010

On Sat, Jan 23, 2010 at 8:21 AM, Robert Jordan <robertj at gmx.net> wrote:
> On 23.01.2010 06:02, Bryan Murphy wrote:
>> Is there a way I can change the name of a mono process for when I'm looking
>> at it via ps or top?
> First, there is no portable way to change the process name.

Though there is a similar call you can make on BSD (hence MacOS X), so
you can use runtime platform detection to choose which call to make.

See the SetProcessName method in

> Under Linux, prctl(2) can be used to change the name. It seems
> that "ps" is still showing the command line, whereas "top" is
> actually considering the new name.

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.

And on MacOSX, there is a third call you can use to override the name
shown in the top menu bar, which is useful if your exe isn't running
from an app bundle. See Carbon.SetProcessName in

Michael Hutchinson

More information about the Mono-list mailing list