title: What will happen if I delete a input file while some program is reading data from that file?
body: <p>If there is a python script doing this :</p>
  
  <pre><code>with open('large_input_file.log', 'rb') as f :
      for each_line in f :
          do something .....
  </code></pre>
  
  <p>Let's call this script <code>a.py</code></p>
  
  <p><code>large_input_file.log</code> is about 16GB. <code>a.py</code> will take hours to process this file.</p>
  
  <p>What will happen if I do this (under Linux):</p>
  
  <ol>
  <li><p>keep <code>a.py</code> running</p></li>
  <li><p>delete <code>large_input_file.log</code></p></li>
  <li><p>replace <code>large_input_file.log</code> with different content but same name</p></li>
  </ol>
  
  <p>Is <code>a.py</code> able to get the correct data in <code>large_input_file.log</code> before I delete it? (I guess this is what will happen.)</p>
  
  <p>Or will <code>a.py</code> get new data starting with the same offset in the new <code>large_input_file.log</code></p>
  
  <p>Can you explain it in kernel level or filesystem level? (How does linux accomplish this)?</p>
  
  <p>-----------------Below is added after some answer------------------------</p>
  
  <p>What if my disk size is 16Gb, so there can be store only one <code>large_input_file.log</code>.</p>
  
  <p>What will happen if I delete <code>large_input_file.log</code> and create another 16Gb <code>large_input_file.log</code> file ?</p>