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 am looking in the Activity Monitor which I believe uses top, but I am not 100% sure.
I have tried $0 = "My process name"
, $0 = "My process name\0"
, $PROGRAM_NAME = "My process name"
, $0 = "my_process_name"
. None of which seem to do the trick.
I have 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 love to have a cross-platform way to do this, but I'm mainly after an OSx way right now.
Similar question without satisfactory answer: Change the ruby process name in top