New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 6 users
Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jan 2010
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug
M-5

Restricted
  • Only users with EditIssue permission may comment.



Sign in to add a comment
Chrome plugins show up as /proc/self/exe in top
Project Member Reported by evan@chromium.org, Dec 1 2009 Back to list
I always get confused about when we can just mutate argv[0] and when we need 
to use setproctitle().  If anyone can instruct me on what to do here I will 
fix it.
 
Comment 1 by mdm@chromium.org, Dec 2 2009
On Linux/glibc there is no official setproctitle(), but we have one that works by mutating 
argv (which is the "approved" way to do it from the kernel's point of view) and has the 
same interface as the BSD version. It has lots of bounds checking and knows how to 
move environment variables out of the way to ensure that we only overwrite the right 
things. It should be used rather than overwriting argv[0] directly.

The kernel has two places where it exposes information about process' names. One, the 
target of /proc/N/exe, is immutable. It contains the full path that was used to execute 
the binary and is only changed on exec*(). The other, /proc/N/cmdline, is a pointer into 
the process' argv array and can be changed by setproctitle(). Some process viewing 
tools only look at the exe symlink; for these tools, there is nothing we can do to change 
what they will display. Other tools will look at cmdline, or have an option to do so - for 
example the c key toggles between these modes in top.

Previously I had thought that all the current GUI tools would only look at the exe link, 
although recently I discovered that at least the GNOME process viewer can be set to 
look at the cmdline instead (although it's not an obvious setting).
Labels: Mstone-5
Status: Available
Comment 3 by mdm@chromium.org, Jan 3 2010
Labels: -Area-Misc Area-Internals
Turns out there is also another way to change process names in Linux: 
prctl(PR_SET_NAME). This changes the short name that shows in top, for instance. I've 
got a CL that puts all these pieces together and fixes this issue ready to check in: 
http://codereview.chromium.org/490028
The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=35441 

------------------------------------------------------------------------
r35441 | mdm@chromium.org | 2010-01-02 18:20:08 -0800 (Sat, 02 Jan 2010) | 5 lines
Changed paths:
   M http://src.chromium.org/viewvc/chrome/trunk/src/base/command_line.cc?r1=35441&r2=35440
   M http://src.chromium.org/viewvc/chrome/trunk/src/base/setproctitle_linux.h?r1=35441&r2=35440
   M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/plugin/plugin_main.cc?r1=35441&r2=35440

Linux: use readlink() and prctl() in SetProcTitle() to fix "exe" showing in process listings.
BUG= 29118 
TEST=none

Review URL: http://codereview.chromium.org/490028
------------------------------------------------------------------------

Comment 5 by mdm@chromium.org, Jan 4 2010
Status: Fixed
The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=35660 

------------------------------------------------------------------------
r35660 | thestig@chromium.org | 2010-01-06 14:50:27 -0800 (Wed, 06 Jan 2010) | 8 lines
Changed paths:
   M http://src.chromium.org/viewvc/chrome/branches/249/src/base/command_line.cc?r1=35660&r2=35659
   M http://src.chromium.org/viewvc/chrome/branches/249/src/base/setproctitle_linux.h?r1=35660&r2=35659
   M http://src.chromium.org/viewvc/chrome/branches/249/src/chrome/plugin/plugin_main.cc?r1=35660&r2=35659

Merge 35441 - Linux: use readlink() and prctl() in SetProcTitle() to fix "exe" showing in process listings.
BUG= 29118 
TEST=none

Review URL: http://codereview.chromium.org/490028

TBR=mdm@chromium.org
Review URL: http://codereview.chromium.org/523106
------------------------------------------------------------------------

Project Member Comment 7 by bugdroid1@chromium.org, Oct 12 2012
Labels: Restrict-AddIssueComment-Commit
This issue has been closed for some time. No one will pay attention to new comments.
If you are seeing this bug or have new data, please click New Issue to start a new bug.
Project Member Comment 8 by bugdroid1@chromium.org, Mar 10 2013
Labels: -Area-Internals -Mstone-5 M-5 Cr-Internals
Project Member Comment 9 by bugdroid1@chromium.org, Mar 13 2013
Labels: -Restrict-AddIssueComment-Commit Restrict-AddIssueComment-EditIssue
Sign in to add a comment