title: Duplicating file descriptor and seeking through both of them independently
body: <p>I have an open file descriptor which I want to duplicate in order to perform reading and seeking through both of them independently. I looked at the </p>
  
  <pre><code>int dup(int old_fd)
  </code></pre>
  
  <p>syscall. The problem is it does not really fit here. Man page states the following 
  <a href="http://man7.org/linux/man-pages/man2/dup.2.html" rel="nofollow noreferrer">http://man7.org/linux/man-pages/man2/dup.2.html</a> :</p>
  
  <blockquote>
    <p>After a successful return, the old and new file descriptors
    may be used interchangeably.  They refer to the same 
    open file description (see open(2)) and thus share file 
    offset and file status flags; for example, if the file offset is 
    modified by using lseek(2) on one of the file descriptors, 
    the offset is also changed for the other.</p>
  </blockquote>
  
  <p>Is there a way to duplicate a file descriptor so they are completely independent?</p>