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 trying to invoke ps -o comm:1024 --pid 1391 --cols 1024 -w in the hope of getting the full process name (and only that), but I always end up with this

COMMAND
notification-ar

while the process name is instead notification-area-applet. I also tried all combinations of -w, --cols and : formatter. cmd and args give the full path and arguments of the process. I might be able to get the process name from these, but still...

share|improve this question

migrated from stackoverflow.com Mar 18 '13 at 9:52

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 2 down vote accepted

The comm field (also /proc/$pid/comm) is limited by the kernel to 16 bytes total (15 characters + terminating NUL byte).

If the system is Linux and you own the process (or are root), you can obtain the executable path by following /proc/$pid/exe using the readlink command.

Otherwise, you will have to use the cmd field (aliases args, command). On Linux it's taken from /proc/$pid/cmdline (which is NUL-separated), so you can also use cut -d "" -f 1 /proc/$pid/cmdline.

Beware that both cmdline and comm can be changed by the process itself.

share|improve this answer

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.