小编Fur*_*ğlu的帖子

dup() 和 close() 系统调用之间有什么关系?

我在网上搜索了这个主题并发现了这个解释,但我无法理解它背后的想法。代码及解释如下..

#include <unistd.h>
...
int pfd;
...
close(1);
dup(pfd);
close(pfd); //** LINE F **//
...

/*The example above closes standard output for the current
processes,re-assigns standard output to go to the file referenced by pfd,
and closes the original file descriptor to clean up.*/
Run Code Online (Sandbox Code Playgroud)

F线是做什么的?为什么它至关重要?

c operating-system

4
推荐指数
1
解决办法
1465
查看次数

标签 统计

c ×1

operating-system ×1