How to get /proc/[pid]/cmdline to contain command arguments?

I am running into an issue where some of my Ubuntu/Debian servers do not show the arguments passed to rake in either top or ps. I have tracked this problem down to a variation in output given by /proc/[pid]/cmdline. This is the file that seems to control what is shown by ps and top. On the servers that correctly show the arguments, the contents of the cmdline file are akin to:

ruby^@/home/user/.rvm/gems/ree-1.8.7-2011.03/bin/rake^@log_file_tailer:run^@

However, on the servers that don't show rake arguments, the output of cmdline looks like

/home/user/.rvm/gems/ree-1.8.7-2011.03/bin/rake^@                                                                                                        ^@^@^@^@^@

That is, the contents of the file are two lines long, but don't contain any information about the arguments passed to rake.

FWIW, the two servers I have that output the cmdline in the less useful format (the one lacking arguments) are running

Linux version 2.6.32-5-amd64 (Debian 2.6.32-46) ([email protected]) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Sun Sep 23 10:07:46 UTC 2012

and

Linux version 3.2.0-23-generic (buildd@crested) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu4) ) #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012

Interestingly, these servers do seem to correctly show the full command line, including arguments, for most commands that I see excluding rake.

Does anyone know how I can get the full command line, including arguments, to be output to cmdline on these servers? I am greatly hoping this won't require an entire recompilation of the kernel (which I have precious little experience with).

-- EDIT -- It's been speculated that it is soley rake that is responsible for setting the contents of /proc/[pid]/cmdline, but that doesn't jibe with the fact that we're running the same version of rake (0.8.7) on the servers that do and don't give us the command line parameters invoked by rake.


Solution 1:

The short answer is: you can't.

Only the process itself has any influence on the contents of /proc/$pid/cmdline. Some tools (ab)use this to override what top and ps display. So either those rake instances have done this, or they simply don't have any arguments to begin with.

If rake uses this trick, and you don't want it to, maybe the rake documentation will tell you how to disable this behaviour.