After some trial and error, I tested following.
'mmtest1' is munmap()'ed, 'mmtest2' is not.
Immediately after excuting this,
># od -h mmtest1
>0000000 0101 0101 0101 0101 0101 0101 0101 0101
>*
>0030000
># od -h mmtest2
>0000000 0202 0202 0202 0202 0202 0202 0202 0202
>*
>0030000
But after few hours(or a day, or after something done...)
># od -h mmtest1
>0000000 0101 0101 0101 0101 0101 0101 0101 0101
>*
>0030000
># od -h mmtest2
>0000000 0000 0000 0000 0000 0000 0000 0000 0000
>*
>0030000
I think I found such behavior at updateing kernel to 1.3.94.
Same at 1.3.95.
Procps does't munmap().
I guess disappearing /etc/psdevtab and mmtest2 are same reason.
-- /* * first of all, create two test files. * dd if=/dev/zero of=mmtest1 bs=12288 count=1 * dd if=/dev/zero of=mmtest2 bs=12288 count=1 */ #include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h>#define LEN 12288 #define FNAM1 "/tmp/mmtest1" #define FNAM2 "/tmp/mmtest2"
main() { caddr_t p; int fd; int i, j;
if ((fd = open(FNAM1, O_RDWR)) < 0) { perror("open"); exit(1); } p = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, 0); if (p == (caddr_t) -1) { perror("mmap"); exit(1); } close(fd); memset((void *) p, 1, LEN); munmap(p, LEN);
if ((fd = open(FNAM2, O_RDWR)) < 0) { perror("open"); exit(1); } p = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, 0); if (p == (caddr_t) -1) { perror("mmap"); exit(1); } close(fd); memset((void *) p, 2, LEN); }
----_--__---_-_-_-__--_-__-__---_-_----_--_-_---_---_---- _/ TANAKA Yoshitomo _// / Suginami-ku Tokyo, Japan _// serow@silkwood.rim.or.jp