du

来自「Algorithms for Image Processing and Comp」· 代码 · 共 57 行

TXT
57
字号
@c ----------------------------------------------------------------------
@node dup, io
@heading @code{dup}
@subheading Syntax

@example
#include <osfcn.h>

int dup(int old_handle);
@end example

@subheading Description

This function duplicates the given file handle.  Both handles refer to
the same file and file pointer. 

@subheading Return Value

The new file handle, or -1 if error.

@subheading Example

@example
do_file(dup(fileno(stdin)));
@end example

@c ----------------------------------------------------------------------
@node dup2, io
@heading @code{dup2}
@subheading Syntax

@example
#include <osfcn.h>

int dup2(int existing_handle, int new_handle);
@end example

@subheading Description

This call causes @var{new_handle} to refer to the same file and file
pointer as @var{existing_handle}.  If @var{new_handle} is an open file,
it is closed. 

@subheading Return Value

The new handle, or -1 on error.

@subheading Example

@example
/* copy new file to stdin stream */
close(0);
dup2(new_stdin, 0);
close(new_stdin);
@end example

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?