读取已用于流式写入的文件有什么缺点?
想知道一个文件是否打开用于写入,并且另一个程序正在 tcl 中递归访问它。
Wondering if one file is open for writing in and another programe is accessing it recursively in tcl.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您有一个唯一的文件描述符,因此您不必担心其他人的文件查找会弄乱您的文件描述符。请注意,数据可能随时发生变化,恕不另行通知。另外,请确保其他程序不会在任何时间点截断该文件;如果确实如此,您可能会突然意外地从无效地址进行读取。如果其他应用程序只是附加数据(如记录器将数据刷新到日志文件中),那么您不必担心这一点。
如果其他应用程序足够敏感,以至于让您的应用程序同时读取文件会弄乱它,那么它应该更改文件权限以在修改文件时拒绝读取访问。
You have a unique file descriptor, so you don't have to worry about someone else's file seek messing up yours. Just be aware that the data can change at any time, without warning. Also, make sure that the other program won't be truncating the file at any point in time; if it does, it can leave you suddenly and unexpectedly reading from an invalid address. If the other app is simply appending data (as in a logger flushing data to a logfile), then you shouldn't have to worry about that.
If the other app is sensitive enough that having your app read the file concurrently would mess it up, then it should be changing the file permissions to deny read access while it is modifying the file.
我认为打开一个已经在另一个进程中打开用于写入的文件进行读取并没有什么害处。根据写入过程缓冲其输出的方式,您可能期望看到的所有数据实际上可能尚未写入文件。
I don't think it's harmful to open a file for reading that's already opened for writing in another process. Depending on how the writing process buffers its output, all the data you might expect to see may not actually be written to the file yet.
我想知道..
当打开一个文件进行读取时,它的内容是否会传输到内存?
那么,如果其他人在打开读取后更改它,是否会影响只想读取它的程序?
I wonder..
When one file is opened for reading, does it contents transfert to memory ?
So, if somebody else change it after it is opened for reading, will it affect the program that only wants to read it ?