Incorrect close() arguments fix
Due to "man 2 dup"
The call:

              fid = dup2(fildes, fildes2);

       shall be equivalent to:

              close(fildes2);
              fid = fcntl(fildes, F_DUPFD, fildes2);
close() std descriptors before dup()
Merge pull request #4 from denis4net/master

Incorrect close() arguments fix