复制文件句柄dup2 函数
来源:互联网 发布:java构造函数调用 编辑:程序博客网 时间:2024/06/11 23:43
函数简介
函数名: dup2
功 能: 复制文件句柄用 法: int dup2(int oldhandle, int newhandle);#include <sys\stat.h> #include <string.h> #include <fcntl.h> #include <io.h> int main(void) { #define STDOUT 1 int nul, oldstdout; char msg[] = "This is a test"; /* create a file */ nul = open("DUMMY.FIL", O_CREAT | O_RDWR, S_IREAD | S_IWRITE); /* create a duplicate handle for standard output */ oldstdout = dup(STDOUT); /* redirect standard output to DUMMY.FIL by duplicating the file handle onto the file handle for standard output. */ dup2(nul, STDOUT); /* close the handle for DUMMY.FIL */ close(nul); /* will be redirected into DUMMY.FIL */ write(STDOUT, msg, strlen(msg)); /* restore original standard output handle */ dup2(oldstdout, STDOUT); /* close duplicate handle for STDOUT */ close(oldstdout); return 0; }
- 复制文件句柄dup2 函数
- 有关dup2(fd,1),复制文件句柄的问题
- 3.12 dup2函数-文件描述符复制
- dup,dup2函数,复制文件描述符
- dup和dup2函数---复制文件描述符
- dup2复制文件描述符
- dup2 复制文件描述符
- 文件重定向dup2函数
- DuplicateHandle复制句柄保护文件
- 3.12 文件I/O_dup和dup2函数
- 文件IO函数,dup&dup2&fcnlt
- 系统函数-文件操作-dup() dup2()
- 文件描述符 dup/dup2函数
- dup2 函数
- dup2函数
- dup2函数
- dup2函数
- linux dup,dup2,dup3 复制一个文件描述符
- 代码腐烂
- 应用程序的关闭
- ubuntu安装java JDK
- Win32 程序 控件风格和预览不一样的问题
- 左连接查询
- 复制文件句柄dup2 函数
- 嵌入式系统开发:C语言中的位结构体
- windows性能监视器API
- Latent Dirichlet Allocation Model学习笔记二
- 转发 tcp server listenner keep alive
- 开源KVM为企业准备好了吗?
- feof()和EOF的用法—— C中文件结尾的判断
- 窗口分割 CSplitterWnd
- iOS多线程编程之Grand Central Dispatch(GCD)介绍和使用