home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / IO / DUP2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  498 b   |  25 lines

  1. /* dup2.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <io.h>
  5. #include <errno.h>
  6.  
  7. int dup2 (int handle1, int handle2)
  8. {
  9.   if (handle2 < 0)
  10.     {
  11.       errno = EINVAL;
  12.       return (-1);
  13.     }
  14.   if (handle2 >= _nfiles)
  15.     {
  16.       errno = EMFILE;
  17.       return (-1);
  18.     }
  19.   if (__dup2 (handle1, handle2) < 0)
  20.     return (-1);
  21.   _files[handle2] = _files[handle1];
  22.   _lookahead[handle2] = _lookahead[handle1];
  23.   return (handle2);
  24. }
  25.