开放,如果我oppen两次相同的文件()会发生什么? [英] open() what happens if I oppen twice the same file?

查看:148
本文介绍了开放,如果我oppen两次相同的文件()会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我打开同一个文件,将它交给一个错误,还是会产生两个不同的文件描述符?例如:

  A =打开(teste.txt,O_RDONLY);
B =打开(teste.txt,O_RDONLY);


解决方案

在这种情况下,你打开这两个文件为只读,你会得到引用相同的文件两个不同的文件描述符。请参见开放手册页了解更多详情。

If I open the same file twice, will it give an error, or will it create two different file descriptors? For example

a = open("teste.txt", O_RDONLY);
b = open("teste.txt", O_RDONLY);

解决方案

In this case, since you're opening both files as read-only, you will get two different file descriptors that refer to the same file. See the man page for open for more details.

这篇关于开放,如果我oppen两次相同的文件()会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆