Can someone explain what dup() in C does?

前端 未结 8 1081
不知归路
不知归路 2021-01-30 23:34

I know that dup, dup2, dup3 \"create a copy of the file descriptor oldfd\"(from man pages). However I can\'t digest it.

As I know file descriptors are just

相关标签:
8条回答
  • 2021-01-31 00:05

    see this page, stdout can be aliased as dup(1)...

    0 讨论(0)
  • 2021-01-31 00:06

    Just a tip about "duplicating standard output".

    On some Unix Systems (but not GNU/Linux)

    fd = open("/dev/fd/1", O_WRONLY);
    

    it is equivalent to:

    fd = dup(1);
    
    0 讨论(0)
提交回复
热议问题