Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Process name and $0
Bertram Scharpf
4/20/2007 8:12:00 AM
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
--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...
1 Answer
Bertram Scharpf
4/20/2007 9:42:00 AM
0
Hi,
Am Freitag, 20. Apr 2007, 17:12:06 +0900 schrieb Bertram Scharpf:
> Running Irb and having a look into the process table looks
> like this:
>
> $ ruby -pe 'sub "\0", "\n"' /proc/30546/cmdline
> irb
> $ cat /proc/30546/stat
> 30546 (irb) S ...
>
> 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.
> [...]
> I cannot find it: How does Irb manage to change the process
> name in its higher sense?
Just when I had dispatched the posting I found it:
The shebang line must be the latter of:
#!/usr/bin/env ruby
#!/usr/bin/ruby
Bertram
--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Process name and $0
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password