Sunday, June 29, 2014

Patching tmux(1)

Using tmux, you might have noticed that when running an application like 'ranger' you will get your window named as 'python'. That's not really descriptive, so I've looked if I can get the real name into my 'tmux' statusbar.

Tmux on linux uses '/proc/<pid>/cmdline' and extracts the last bit of path of the first field. That's the value to be the window name. Examining proc(5) filesystem, there is a field called 'comm' and corresponds to:

$ ps -p $PID -o comm=

From kernel documentation:

3.6 /proc/<pid>/comm  & /proc/<pid>/task/<tid>/comm
--------------------------------------------------------
These files provide a method to access a tasks comm value. It also allows for
a task to set its own or one of its thread siblings comm value. The comm value
is limited in size compared to the cmdline value, so writing anything longer
then the kernel's TASK_COMM_LEN (currently 16 chars) will result in a truncated
comm value.

So I've made a patch.

It reads the 'comm' with fallback to 'cmdline' if it doesn't exit (not likely using newer kernel). If program name is longer than 15 characters it will be truncated.

1 comment :

  1. These embody meals and chemical processing firms, the pharmaceutical trade,railway, army and defence properly as|in addition to} theautomotiveandaircraft industries. Some mass manufacturing processes first rely upon making dedicated molding or casting dies, similar to with plastic injection molding or investment casting. These dies take significantly longer to make and require a big initial monetary investment. The only way to get well value of|the worth of} this investment, from the perspective of the developer, is to commit to making giant quantity of|numerous|a lot of} completed products over time. Now, digital motors, refined software program, and specialised chopping instruments make this degree of perfection easily achievable and Satin Boxers utterly reliable. Therefore, medical product designers now not have to ask—can or not it's done?

    ReplyDelete