int main()
{
int fdold;
int fdnew=10;
int fdtest;
if((fdold=open("test",O_RDONLY|O_CREAT,0666))<0)
{
perror("open file fail"
exit(1);
}
printf("now the fdnew is :%d\n",fdnew);
fdtest=dup2(fdold,fdnew);
printf("the return value is:%d\n",fdtest);
printf("the old is :%d\nthe new is :%d\n",fdold,fdnew);