d********f 发帖数: 8289 | | 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 还是必须close了,重新open啊? : 谢谢。
| S*A 发帖数: 7142 | 3 fd 是 file descriptor, 为什么是 process id? 不太明白。 process 是
另外一个概念啊。
【在 W***o 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : sorry, 我没有说清楚。我是说比如fp1 = fdopen(fd, "r"); 用过之后还能够做fp2 = : fdopen(fd, "r")吗?还是要先close了fp1?可是close了fp1, fd也就被close了, : right? : : process
| a9 发帖数: 21638 | 6 得共享读才可以打开多次吧、
fp2
【在 p****f 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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. : : =
|
|