title: How can I detect that a file descriptor was redefined to a new filehandle?
body: <p>In this code:</p>
  
  <pre class="lang-perl prettyprint-override"><code>open my $fh1,'&gt;','file1';
  my $fh1_desc=fileno $fh1;
  close $fh1;
  
  open my $fh2,'&gt;','file2';
  
  open my $fh1_,'&gt;&amp;=',$fh1_desc;
  
  if (fileno $fh1_ == fileno $fh2 ) {
      print "\$fh1_ and \$fh2 are dups\n";
  }
  </code></pre>
  
  <p>After that <code>$fh1_</code> and <code>$fh2</code> point to the same file. How can I detect that the redefinition of file descriptor?</p>
  
  <p>This is "dummy code"! The real case is: <br>
  When I pass the file descriptor to a different thread how can I know that it wasn't redefined?</p>