---
name: "fd_copy"
section: "3"
platform: "linux"
package: "qmail"
version: "1.06-6.2~deb10u1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/fd_copy"
---

# fd\_copy(3)

duplicate a descriptor

## NAME

fd\_copy - duplicate a descriptor

## SYNTAX

**#include \<fd.h\>**

int **fd\_copy**(*to*,*from*);

int *to*;\
 int *from*;

## DESCRIPTION

**fd\_copy** copies  descriptor *from* to descriptor *to*. If *to* was already open, **fd\_copy** closes it. **fd\_copy** always leaves *from* intact; if *to* and *from* are the same number, **fd\_copy** does nothing.

**fd\_copy** returns 0 on success, -1 on error. **fd\_copy** does not guarantee that *to* will remain open, if it was open, in case of error.

## SEE ALSO

[dup(2)](/dup/2.md), [fd\_move(3)](/fd_move/3.md)
