attachproc curiously uses a constant variable set to ORDWR, a remnant of some earlier code. instead of always forcing ORDWR for register access, why not try it, and if it can't be opened read-write, use read-only instead. Reference: /n/sources/patch/applied/libmach-map-open Date: Fri Mar 1 15:49:21 CET 2013 Signed-off-by: charles.forsyth@gmail.com --- /sys/src/libmach/map.c Fri Mar 1 15:47:45 2013 +++ /sys/src/libmach/map.c Fri Mar 1 15:47:43 2013 @@ -84,7 +84,6 @@ int fd; Map *map; uvlong n; - int mode; map = newmap(0, 4); if (!map) @@ -93,10 +92,11 @@ regs = "kregs"; else regs = "regs"; - mode = ORDWR; if (mach->regsize) { sprint(buf, "/proc/%d/%s", pid, regs); - fd = open(buf, mode); + fd = open(buf, ORDWR); + if(fd < 0) + fd = open(buf, OREAD); if(fd < 0) { free(map); return 0; @@ -105,7 +105,9 @@ } if (mach->fpregsize) { sprint(buf, "/proc/%d/fpregs", pid); - fd = open(buf, mode); + fd = open(buf, ORDWR); + if(fd < 0) + fd = open(buf, OREAD); if(fd < 0) { close(map->seg[0].fd); free(map);