|
|
1.1 root 1: /*
2: * libc/sys/i386/dup2.c
3: * Copyright (c) Bureau d'Etudes Ciaran O'Donnell,1987,1990,1991.
4: */
5:
6: #include <sys/types.h>
7: #include <sys/stat.h>
8: #include <errno.h>
9: #include <fcntl.h>
10:
11: int
12: dup2(fd1, fd2) register int fd1, fd2;
13: {
14: register int save;
15: struct stat statb;
16:
17: save = errno;
18: if (fstat(fd1, &statb)<0) {
19: errno = EBADF;
20: return -1;
21: }
22: if (fd1==fd2)
23: return fd1;
24: close(fd2);
25: errno = save;
26: return fcntl(fd1, F_DUPFD, fd2);
27: }
28:
29: /* end of libc/sys/i386/dup2.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.