forked from solidco2/node-dup2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
6 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
node-dup2 | ||
========= | ||
There isn't any way for us to redirect #1(fd) to any other file, before I born. | ||
|
||
好吧,我是说,node里面没有dup2函数(当然你可以先关掉一个文件描述符,然后立即打开一个文件),我的出现就是用来提供dup2支持的。 | ||
Demo | ||
require("node-dup2").invoke(oldfd, newfd); | ||
此句会先关掉newfd文件描述符,而克隆oldfd的文件打开状态到newfd上。 | ||
失败时返回-1 |