【发布时间】:2018-07-25 20:09:28
【问题描述】:
我想在 golang 中读取 mmap 文件。
另一个进程正在向其中写入内容,因此它的大小在读取时会增长。
我正在使用
syscall.Mmap(fd int, offset int64, length int, prot int, flags int)
这将返回一个字节数组。
我需要继续syscall.Mmap 来阅读更新的 mmap 吗?有更好的方法吗?
【问题讨论】:
-
另一个进程正在写入你进程的虚拟内存?这通常是不可能的。我认为您误解了
mmap系统调用的作用。 -
@MarcoBonelli:
MAP_SHARED允许在进程之间共享。来自mmap手册页:Updates to the mapping are visible to other processes mapping the same region -
@JimB 哦,那是我的错,不知道
MAP_SHARED,谢谢你的信息。
标签: go system-calls mmap