Changing the name of a Ruby process on OSx

I am trying to give my Ruby program a different name. I am running this on OSx with Ruby version 2.1.2-p95. I look in the Activity Monitor , which, it seems to me, uses the top one, but I'm not 100% sure.

I tried $0 = "My process name", $0 = "My process name\0", $PROGRAM_NAME = "My process name", $0 = "my_process_name". None of them seem to do the trick.

I also tried:

require "fiddle"
def set_process_name(name)
    Fiddle::Function.new(
        DL::Handle["prctl"], [
            Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP,
            Fiddle::TYPE_LONG, Fiddle::TYPE_LONG,
            Fiddle::TYPE_LONG
        ], Fiddle::TYPE_INT
    ).call(15, name, 0, 0, 0)
end
set_process_name("My process name")

I would like to have a cross-platform way to do this, but I'm mostly after OSx right now.


A similar question without a satisfactory answer: Change the ruby ​​process name at the top

+4
source share
1 answer

- . - Process.setproctitle, OSX , Activity Monitor.

OSX script Info.plist

+2

All Articles