From: "Iñaki Baz Castillo" Date: 2009-12-12T22:49:46+09:00 Subject: Re: Is it possible to force a Ruby program to run as a proc name different than "ruby"? El Sábado, 12 de Diciembre de 2009, Brian Candler escribió: > Brian Candler wrote: > > Iñaki Baz Castillo wrote: > >> So, is there some way to force the process to appear as "rb_program" in > >> /proc/PID/status? > > > > Have you tried > > > > $0 = 'rb_program' > > > > ? > > ... or I can't remember the details, but perhaps you needed > $0.replace('rb_program'), but that doesn't work for newer versions of > > Ruby where $0 is a frozen string, hence the required special code: > > $progname = $0 > > alias $PROGRAM_NAME $0 > > alias $0 $progname > > trace_var(:$0) {|val| $PROGRAM_NAME = val} # update for ps Thanks a lot, it sounds really interesting. However all the above works for me just by adding at the top: $0 = "rb_program" or: $PROGRAM_NAME = "rb_program" With it when I do a "ps" I see "rb_program" which is great. However in /proc/PID/status I still have the same described issues: "Name: ruby1.9", so I cannot do "killall rb_program". This can be solved by using: #!/usr/local/bin/ruby1.9 rather than: #!/usr/bin/env ruby1.9 but of course hardcoding the location of ruby is not very good approach (specially when you want your code to run on any Linux system). Thanks a lot. -- Iñaki Baz Castillo