want workaround for "dup2"

Mariusz Stanczak Mariusz at fbits.ttank.com
Mon Mar 18 17:52:22 AEST 1991

In article <1270 at hico2.UUCP>, kak at hico2.UUCP (Kris A. Kugel) writes:
> Hummm... I don't seem to have "dup2" either.
> [...]
> Is there an easy way to provide dup2?

The following version was included with GNU `make'

dup2 (old, new)
     int old, new;
  int newfd;

  (void) close (new);
  newfd = fcntl (old, F_DUPFD, new);
  if (newfd == -1)
    return -1;

  if (newfd != new)
      (void) close (newfd);
      errno = EMFILE;
      return -1;

  return newfd;

INET: Mariusz at fbits.ttank.com
CIS : 71601.2430 at compuserve.com
UUCP: ..!uunet!zardoz!ttank!fbits!Mariusz

More information about the Comp.sys.3b1 mailing list