Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Sep 2007 12:27:10 +0500
From:      rihad <rihad@mail.ru>
To:        Anton Berezin <tobez@tobez.org>
Cc:        freebsd-perl@freebsd.org
Subject:   Re: top(1) process name
Message-ID:  <46F0CF4E.201@mail.ru>
In-Reply-To: <20070918143102.GC55827@heechee.tobez.org>
References:  <46EFBF75.2030009@mail.ru> <20070918143102.GC55827@heechee.tobez.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Anton Berezin wrote:
> On Tue, Sep 18, 2007 at 05:07:17PM +0500, rihad wrote:
> 
>> This is probably a FAQ. Is there any way to set the process name of a 
>> running Perl program displayed in top(1)?
>>
>> $0 = 'candy';
>>
>> doesn't seem to affect it in any way (although it does change what ps 
>> displays).
> 
> I do not believe it is possible in modern FreeBSDs.  The top(1) utility uses
> kvm_getprocs(3), which guarantees that the ki_comm field will represent an
> unaltered original command name, so no amount of tinkering with
> setproctitle(3) or the contents of argv array will change that.
> 
> Accidentally, ps -c does the same.
> 
> If there is a way to do it, I will be happy to learn about it myself.
> 

I hacked it by hardlinking the desired name to perl:

# ln /root/candy /usr/local/bin/perl
# cat /path/to/my/perl/script
#!/root/candy
...


Good enough for me.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46F0CF4E.201>