On my development box, under /proc/[pid]/ there is a file called comm containing the name of the executable for that process. I use this to validate the process to which I am sending a signal. On our live server it does not exist. Both machines are running Ubuntu 12.04.3 LTS (albeit the live server is virtualised). On the live machine the executable exists in cmdline but of course with command line arguments which have to be parsed out. Why does one instance have comm and not the other?

  • Are both machines running the stock Ubuntu kernel? – cpugeniusmv Oct 23 '13 at 6:30
  • I am starting to suspect that this is a 2.6 vs. 3.x issue since the virtualised server instance reports the 2.6.32 kernel and my development machine is running 3.2.0-55. I would like to know for sure though. In both cases /etc/issue reports the same OS. – David G Oct 23 '13 at 17:38

It's possible that your virtual machine's kernel is either too old or not configured to provide the /proc/PID/comm file.

According to the proc(5) man page, you may be able to use the second field in /proc/[pid]/stat. It is described as:

The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out.

The name of the command may be truncated if it is longer than 16 characters.

  • I think this must be what's going on. I ended up using comm if it exists and falling back to parsing cmdline if not. I'm accepting this as best answer. – David G Oct 29 '13 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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