Messages in this thread | | | Date | Fri, 11 Jul 1997 20:17:29 +0300 (EET DST) | From | Valerij Shchedrin <> | Subject | mmap trouble |
| |
Hello All!
When I create file and write to it something (file size != 0), then all is OK. But when open creates new file, or opens file with size == 0, then SIGBUS occurs. Why??? (I use 2.0.30 kernel). As gdb says SIGBUS occurs on first write to buf asm instruction (in strcpy). Any cure????
=== Cut === #include <sys/mman.h> #include <fcntl.h> #include <unistd.h> #include <string.h>
main() { int fd;
fd = open("test.file", O_CREAT | O_RDWR, 0644); buf = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); strcpy(buf, "Hello, World!"); msync(buf, 4096); munmap(buf, 4096); close(fd); } === Cut ===
Valery Shchedrin o728@gu.kiev.ua
| |