Table of Contents

Method dup2

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

dup2(int, int)

Duplicates a file descriptor, replacing the target file descriptor if it is already open.

public static extern int dup2(int oldfd, int newfd)

Parameters

oldfd int

The file descriptor to duplicate.

newfd int

The target file descriptor to replace. If newfd is already open, it will be closed before duplication.

Returns

int

0 on success; otherwise, -1 if an error occurs. Check the global errNo variable for error details.

Remarks

This method is a P/Invoke wrapper for the dup2 function in the C standard library. It is used to duplicate file descriptors, ensuring that newfd refers to the same open file description as oldfd.