unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (HP-UX-11.11)
Page:
Section:
Apropos / Subsearch:
optional field



 dup(2)								      dup(2)




 NAME
      dup - duplicate an open file descriptor

 SYNOPSIS
      #include <&lt&lt&lt;unistd.h>&gt&gt&gt;

      int dup(int fildes);

 DESCRIPTION
      fildes is a file descriptor obtained from a creat(), open(), dup(),
      fcntl(), or pipe() system call.  dup() returns a new file descriptor
      having the following in common with the original:

	   +  Same open file (or pipe).

	   +  Same file pointer (i.e., both file descriptors share one file
	      pointer).

	   +  Same access mode (read, write or read/write).

	   +  Same file status flags (see fcntl(2), F_DUPFD).

      The new file descriptor is set to remain open across exec() system
      calls.  See fcntl(2).

      The file descriptor returned is the lowest one available.

 RETURN VALUE
      Upon successful completion, the file descriptor is returned as a non-
      negative integer.	 Otherwise, a value of -1 is returned and errno is
      set to indicate the error.

 ERRORS
      dup() fails if one or more of the following is true:

      [EBADF]		       fildes is not a valid open file descriptor.

      [EMFILE]		       Request violates the maximum number of open
			       file descriptors.

 AUTHOR
      dup() was developed by AT&T and HP.

 SEE ALSO
      close(2), creat(2), dup2(2), exec(2), fcntl(2), open(2), pipe(2).

 STANDARDS CONFORMANCE
      dup(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1






 Hewlett-Packard Company	    - 1 -   HP-UX Release 11i: November 2000