Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am developing a node application and there is an option to set the process title (process name). This only sets it in some tools (like ps and top), but not in htop or netstat.

I found this article that explained how most applications do it, but it doesn't change in netstat.

That lead me to wonder where those programs are getting the process name. Would they be getting it from /proc/##/cmdline? (## being the PID of the process)

I figure messing with things in /proc is a bad idea (and probably not possible), so if this is where those programs are getting it, is there a way to change it?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

There is nothing wrong with reading things from /proc. In fact, that is where those tools get that information from. There are actually three files with the command name.

/proc/PID/cmdline
/proc/PID/stat
/proc/PID/status

I believe it is usually obtained from stat.

share|improve this answer
    
But why do ps and top have the changed process name, whereas netstat doesn't? –  tjameson Jun 25 '11 at 7:27
    
Apparently a process can change it's name, which changes /proc/PID/cmdline, but the stat entry does not change. So it depends on which place the tool looks to get the name. netstat seems to use the stat entry. –  Keith Jun 25 '11 at 8:03
    
Apparently node was changing the values in stat, status, and comm, but not cmdline. I guess programs like htop and netstat read from cmdline. Anyway, thanks for the info! –  tjameson Jun 25 '11 at 18:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.