由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - fdopen能open同一个fd 两次吗?
相关主题
pollsys 是干嘛的?python和java里面非memory资源怎么回收?
问问跟Linux Kernel Programming 有关的问题[合集] 请教一个Linux系统编程的问题
请教c/c++如何在linux下查询process status[合集] 我也花了一小时读了一下python
关于STDERR定向到文件问题不会写pipe大虾帮帮忙吧...
一道c++ 题, 找出duplicate numberspython descriptor 问题
An algorithm question[请教]命令行的重定向
问个构造函数的问题100伪币答谢Linux/Unix编程问题 (转载)
does the system guarantee this? (转载)Socket accept failed - WSAEMFILE
相关话题的讨论汇总
话题: fd话题: fdopen话题: open话题: close话题: file
进入Programming版参与讨论
1 (共1页)
d********f
发帖数: 8289
1
还是必须close了,重新open啊?
谢谢。
W***o
发帖数: 6519
2
sorry, I misspoke. fd is just an index in the file table of your own process
, fd is not a PID. To answer your question, another open is not necessary,
because the fd stays in the file table until you close it.

【在 d********f 的大作中提到】
: 还是必须close了,重新open啊?
: 谢谢。

S*A
发帖数: 7142
3
fd 是 file descriptor, 为什么是 process id? 不太明白。 process 是
另外一个概念啊。

【在 W***o 的大作中提到】
: sorry, I misspoke. fd is just an index in the file table of your own process
: , fd is not a PID. To answer your question, another open is not necessary,
: because the fd stays in the file table until you close it.

d********f
发帖数: 8289
4
sorry, 我没有说清楚。我是说比如fp1 = fdopen(fd, "r"); 用过之后还能够做fp2 =
fdopen(fd, "r")吗?还是要先close了fp1?可是close了fp1, fd也就被close了,
right?

process

【在 W***o 的大作中提到】
: sorry, I misspoke. fd is just an index in the file table of your own process
: , fd is not a PID. To answer your question, another open is not necessary,
: because the fd stays in the file table until you close it.

p****f
发帖数: 251
5
you can open a file as many time as you can, each FP point to different
entry in the kernel, unless you do system call dup, which will only
duplicate the descriptor.

=

【在 d********f 的大作中提到】
: sorry, 我没有说清楚。我是说比如fp1 = fdopen(fd, "r"); 用过之后还能够做fp2 =
: fdopen(fd, "r")吗?还是要先close了fp1?可是close了fp1, fd也就被close了,
: right?
:
: process

a9
发帖数: 21638
6
得共享读才可以打开多次吧、

fp2

【在 p****f 的大作中提到】
: you can open a file as many time as you can, each FP point to different
: entry in the kernel, unless you do system call dup, which will only
: duplicate the descriptor.
:
: =

l*********s
发帖数: 5409
7
re

【在 p****f 的大作中提到】
: you can open a file as many time as you can, each FP point to different
: entry in the kernel, unless you do system call dup, which will only
: duplicate the descriptor.
:
: =

1 (共1页)
进入Programming版参与讨论
相关主题
Socket accept failed - WSAEMFILE一道c++ 题, 找出duplicate numbers
有对USB audio class的descriptor熟悉的XD吗?An algorithm question
linux select(): can file descriptors be dynamtic ?问个构造函数的问题
我来尽量客观地谈谈GC/ref count,还有RAIIdoes the system guarantee this? (转载)
pollsys 是干嘛的?python和java里面非memory资源怎么回收?
问问跟Linux Kernel Programming 有关的问题[合集] 请教一个Linux系统编程的问题
请教c/c++如何在linux下查询process status[合集] 我也花了一小时读了一下python
关于STDERR定向到文件问题不会写pipe大虾帮帮忙吧...
相关话题的讨论汇总
话题: fd话题: fdopen话题: open话题: close话题: file