pmap: print process even if smaps unreadable
pmap would previously print the process name if /proc/PID/smaps could be opened, even if subsequent reads failed. This actually occurs with other users PIDs. Kernel 3.18rc1 introduced a change where the file could not been opened, meaning pmap -X 1 previously showed the process name and nothing else but NOW shows nothing make check failed because of this. This change prints the process name even before trying to open the file, returning it to previous behaviour. Thanks to Vincent Bernat for some analysis. References: https://bugs.debian.org/775624 https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=29a40ace841cba9b661711f042d1821cdc4ad47c Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
parent
96c524990b
commit
92071e963e
1
NEWS
1
NEWS
@ -2,6 +2,7 @@ procps-ng-NEXT
|
||||
----------------
|
||||
* pgrep: don't crash with -a -w flags. Merge 33, Debian #768190
|
||||
* skill: command line with signal number interpreted correctly
|
||||
* pmap: print process name even if smaps is unreadable Debian #775624
|
||||
|
||||
procps-ng-3.3.10
|
||||
----------------
|
||||
|
8
pmap.c
8
pmap.c
@ -533,6 +533,10 @@ static int one_proc(proc_t * p)
|
||||
*/
|
||||
int maxcmd = 0xfffff;
|
||||
|
||||
escape_command(cmdbuf, p, sizeof cmdbuf, &maxcmd,
|
||||
ESC_ARGS | ESC_BRACKETS);
|
||||
printf("%u: %s\n", p->tgid, cmdbuf);
|
||||
|
||||
if (x_option || X_option || c_option) {
|
||||
sprintf(buf, "/proc/%u/smaps", p->tgid);
|
||||
if ((fp = fopen(buf, "r")) == NULL)
|
||||
@ -543,10 +547,6 @@ static int one_proc(proc_t * p)
|
||||
return 1;
|
||||
}
|
||||
|
||||
escape_command(cmdbuf, p, sizeof cmdbuf, &maxcmd,
|
||||
ESC_ARGS | ESC_BRACKETS);
|
||||
printf("%u: %s\n", p->tgid, cmdbuf);
|
||||
|
||||
if (X_option || c_option) {
|
||||
print_extended_maps(fp);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user