Bug 1122977

Summary: A process can have multiple names and there is no single way to update them all
Product: [Fedora] Fedora Reporter: Nikos Mavrogiannopoulos <nmavrogi>
Component: kernelAssignee: Kernel Maintainer List <kernel-maint>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: gansalmon, itamar, jonathan, kernel-maint, madhu.chinakonda, mchehab
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-24 14:21:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nikos Mavrogiannopoulos 2014-07-24 13:49:16 UTC
There are multiple ways to obtain a process name in Linux:
 1. /proc/PID/cmdline: The command line arguments that were passed (including argv[0] which is the process name)
 2. /proc/PID/comm: The name of the command used, that can be initially equal to argv[0].

Method (1) is read by "ps -ef", and the way for a program to overwrite it is via questionable code like:
https://github.com/karelzak/util-linux/blob/master/lib/setproctitle.c
https://gitorious.org/libsetproctitle/libsetproctitle/source/50e52b1ca62aacc111832f1e0078b55110534c6e:setproctitle.c

Method (2) is read by "ps -e" or top and the way for a program to overwrite it is via prctl(PR_SET_NAME).

When overwriting the process name using prctl() or the setproctitle() above, only one of the /proc entries is updated leaving multiple names on a single process. That makes process name changing on a Linux system an interesting adventure. Some programs use the setproctitle() hack, while others the prctl() call, making process listing inconsistent. That is, some overwritten names show in ps -e for some programs, while for other programs they show in ps -ef. The procps maintainers believe that this isn't an issue of procps but rather of the kernel itself (see #1107682), and I tend to concur.

I believe there should be a simple way for applications to overwrite their name.

Comment 1 Josh Boyer 2014-07-24 14:21:20 UTC
Please take this to the upstream kernel developers.