Hi,
the following might be Linux specific.
Running Irb and having a look into the process table looks
like this:
$ ps aux | grep [i]rb
user 30546 1.3 1.0 7880 5328 pts/3 S+ 09:49 0:00 irb
$ ps -A | grep irb
30546 pts/3 00:00:00 irb
$ pgrep irb
30546
$ ruby -pe ‘sub “\0”, “\n”’ /proc/30546/cmdline
irb
$ cat /proc/30546/stat
30546 (irb) S …
$ cat /etc/gentoo-release
Gentoo Base System release 1.12.9
Now, I’m running a daemon written in Ruby that I want to
appear under its own name rather than “ruby” in ps, pstree,
top and so forth.
Having a look at Irb’s source code and at
rb_define_hooked_variable()' in
ruby.c’ shows me that
setting $0 does at least partially what I want. It works for
the ‘ps -A’ call and for the ‘cmdline’ output. ‘pgrep’ still
doesn’t respond and ‘stat’ still contains “ruby”.
I cannot find it: How does Irb manage to change the process
name in its higher sense?
Thanks for any hints in advance.
Bertram