/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that returns a duplicate an open file descriptor*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int main() {
    int fp1,fp2;
    
    /* open file for reading only */
    if((fp1 = open("dup.c",O_RDONLY)) == -1){
      printf("cannot open file\n");
      exit(1);
    }
    fp2=dup(fp1);
    if(fp2 > 0)
	printf("Successful duplication of a file descriptor.\n");
    close(fp2);
}
