On Sat, Jan 24, 2015 at 08:25:20AM +0100, Vincent Bernat wrote:
>  ❦ 24 janvier 2015 13:40 +1100, Craig Small <csm...@debian.org> :
> > open("/proc/1/smaps", O_RDONLY)         = 3

> With 3.18:
> 
> open("/proc/1/smaps", O_RDONLY)         = -1 EACCES (Permission denied)
Ah ha, there we have it (and confirmed in your next email around the
kernel change).

I'll pull the printing of the process ahead of the open and we should
all be good, or at least consistent.

My guess is whenever this was written, noone would of thought you
could open a file then hit a permission denied on the read of that
file descriptor.

I'm not sure if you are able to, but if you could apply the
attached patch to see if the test works now that would be
great.

make
make test (fails)
apply patch
make
make test (works)

> Same as for more.
My more shows different to cat.
I think the kernel patch will give a more consistent look to a lot
of things that use that file.

 - Craig

-- 
Craig Small (@smallsees)   http://enc.com.au/       csmall at : enc.com.au
Debian GNU/Linux           http://www.debian.org/   csmall at : debian.org
GPG fingerprint:        5D2F B320 B825 D939 04D2  0519 3938 F96B DF50 FEA5
diff --git a/pmap.c b/pmap.c
index c83617c..17e0e30 100644
--- a/pmap.c
+++ b/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;

Reply via email to