On Sun, 2001-09-23 at 11:12, Ben Wing wrote:
 
 My general solution for Unix, while [hopefully, i.e. i haven't tested it]
 something that actually works, is clearly pretty clunky.  Can anyone suggest a
 better way, even if it only works on some systems?
 
 I notice, for example, that there's an mprotect[] system call under Linux and
 others that lets you change the protections of a page of memory; but there's no
 corresponding call I could find to retrieve the current memory settings. 
at least for linux you can read /proc/getpid()/maps. the first field is
the start of the memory range, the second field the end and the third
field the protections. for example:
08048000-0817f000 r-xp 00000000 08:06 32326      /usr/local/bin/xemacs-21.1.12
0817f000-08465000 rw-p 00136000 08:06 32326      /usr/local/bin/xemacs-21.1.12
08465000-08a03000 rwxp 00000000 00:00 0
40000000-40015000 r-xp 00000000 08:09 48290      /lib/ld-2.2.4.so
40015000-40016000 rw-p 00014000 08:09 48290      /lib/ld-2.2.4.so
40016000-40017000 r--p 00000000 08:05 516648     /usr/lib/locale/en_US/LC_IDENTIFICATION
40017000-4001d000 r--s 00000000 08:05 228717     /usr/lib/gconv/gconv-modules.cache
4001d000-4001e000 r--p 00000000 08:05 180600     /usr/lib/locale/en_US/LC_MEASUREMENT
4001e000-4001f000 r--p 00000000 08:05 244664     /usr/lib/locale/en_US/LC_TELEPHONE
4001f000-40020000 r--p 00000000 08:05 244666     /usr/lib/locale/en_US/LC_ADDRESS
40020000-40021000 r--p 00000000 08:05 244665     /usr/lib/locale/en_US/LC_NAME
40021000-40022000 r--p 00000000 08:05 548528     /usr/lib/locale/en_US/LC_PAPER
40022000-40023000 r--p 00000000 08:05 580642    
/usr/lib/locale/en_US/LC_MESSAGES/SYS_LC_MESSAGES
40023000-40024000 r--p 00000000 08:05 176026     /usr/lib/locale/en_US/LC_MONETARY
40024000-4002a000 r--p 00000000 08:05 496011     /usr/lib/locale/en_US/LC_COLLATE
4002a000-4002b000 r--p 00000000 08:05 516649     /usr/lib/locale/en_US/LC_TIME
4002b000-4002c000 r--p 00000000 08:05 580641     /usr/lib/locale/en_US/LC_NUMERIC
4002e000-4002f000 rw-p 00000000 00:00 0
4002f000-40070000 r-xp 00000000 08:05 449444     /usr/lib/libtiff.so.3.5
40070000-40072000 rw-p 00040000 08:05 449444     /usr/lib/libtiff.so.3.5
[deleted]
409d7000-409d8000 rw-p 00002000 08:05 451299     /usr/lib/libimlib-png.so
bff5c000-c0000000 rwxp fff5d000 00:00 0
the third line is the allocated heap, the last line is the stack.
 
 ben 
-- 
Michael Lausch
See my web page <
http://www.lausch.at/> or query PGP key server for PGP
key.
"Reality is that which, when you stop believing in it, doesn't go away".
                -- Philip K. Dick