File:  [MW Coherent from dump] / coherent / b / lib / libc / sys / i386 / dup2.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * libc/sys/i386/dup2.c
 * Copyright (c) Bureau d'Etudes Ciaran O'Donnell,1987,1990,1991.
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>

int
dup2(fd1, fd2) register int fd1, fd2;
{
	register int save;
	struct stat statb;

	save = errno;
	if (fstat(fd1, &statb)<0) {
		errno = EBADF;
		return -1;
	}
	if (fd1==fd2)
		return fd1;
	close(fd2);
	errno = save;
	return fcntl(fd1, F_DUPFD, fd2);
}

/* end of libc/sys/i386/dup2.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.