Shachar Shemesh wrote:
Hi all,
I'm having some strange time with /proc/<pid>/mem. The manual page says:
/proc/[number]/mem
This file can be used to access the pages of a process's
memory through open(2), read(2), and lseek(2).
Some digging through the internet reveals that that is, indeed, the
case, but the process doing the reading must be attached to the process
whose memory is being accessed as a debugger. Well, so far so good.
However, when I go out to actually try it out (program at end of mail),
I can access the file as neither read nor write. Any attempt to read
from the file OR mmap it (PROT_READ or otherwise) results in "invalid
argument".
I am running Debian Lenny with kernel 2.6.22-3-686.
on ubuntu 6.10 (kernel 2.6.17-12-386) this fails in the same way.
i changed the initial memory allocation to use malloc instead of mmap -
and then the parren manages to read the contents of the buffer from the
child's /proc/pid/mem. however, when it tries to mmap this memory - it
fails:
[EMAIL PROTECTED]:~$ ./a.out
Created child 9677
Memory dump contains "String1"
mmap(/proc/son/mem) failed: Invalid argument
so there's a problem when combining /proc/pid/mem with mmap - perhaps it
doesn't work well for mmapped-files...
--guy
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]