Following is the same code for Ruby
# 1.rb
$0 = "program"
sleep 100
╰─ $ ruby 1.rb &
[1] 578277
╰─ $ ps aux |grep program
zw963 578277 0.3 0.0 88220 17972 pts/1 S 16:33 0:00 program
Thanks
Following is the same code for Ruby
# 1.rb
$0 = "program"
sleep 100
╰─ $ ruby 1.rb &
[1] 578277
╰─ $ ps aux |grep program
zw963 578277 0.3 0.0 88220 17972 pts/1 S 16:33 0:00 program
Thanks
There is currently no (portable) API for changing the name of the process in Crystal’s standard library.
You can use platform-specific mechanism, such as pthread_setname
, prctl(PR_SET_NAME)
or writing to /proc/self/comm
.
The latter is probably easiest because it doesn’t need any bindings. It works on Linux, but only for ps
, not ps u
.
File.write("/proc/self/comm", "program")
puts `ps | grep program` # => "29496 pts/4 00:00:00 program"