title: What is the Android ProcessKiller?
body: <p>Does anybody know about the ProcessKiller process on Android? It seems that it kills my App because it has an opened file. It happens when I am downloading a file to the SD card and then pull out the card during the download. That's what logcat says.</p>
  
  <pre><code>E/ProcessKiller( 2447): Process com.example.myapp (24090) has open file /storage/sda1/MyRecordings/81321226.recording/downloading/00000149.ts
  E/ProcessKiller( 2447): Process com.example.myapp (24090) has open file /storage/sda1/MyRecordings/81321226.recording/downloading/00000149.ts
  E/ProcessKiller( 2447): Process com.example.myapp (24090) has open file /storage/sda1/MyRecordings/81321226.recording/downloading/00000149.ts
  E/ProcessKiller( 2447): Process com.example.myapp (24090) has open file /storage/sda1/MyRecordings/81321226.recording/downloading/00000149.ts
  E/ProcessKiller( 2447): Process com.example.myapp (24090) has open file /storage/sda1/MyRecordings/81321226.recording/downloading/00000149.ts
  E/ProcessKiller( 2447): Process com.example.myapp (24090) has open file /storage/sda1/MyRecordings/81321226.recording/downloading/00000149.ts
  E/ProcessKiller( 2447): Process com.example.myapp (24090) has open file /storage/sda1/MyRecordings/81321226.recording/downloading/00000149.ts
  E/ProcessKiller( 2447): Process com.example.myapp (24090) has open file /storage/sda1/MyRecordings/81321226.recording/downloading/00000149.ts
  </code></pre>
  
  <p>I cannot properly close the file because it is a temporary file that I download and this happens when the user pulls out the sd card during a download. So I don't have access to the file anymore and because of this cannot close the FileOutputStream.</p>
  
  <p>That's how I try to close the file after an IOException has been thrown (it throws an error as well). "fos" is a FileOutputStream:</p>
  
  <pre><code>finally         
  {               
     try
     {
       Log.d(TAG, "Closing output file stream for file " + currentSegmentFile.getName());
      fos.flush();
      fos.getFD().sync();
      fos.close();
      }
      catch (IOException e1)
      {
         Log.d(TAG, "Error closing file " + e1.getLocalizedMessage());
  
         throw e1;
      }
  }
  </code></pre>
  
  <p>So as I can't close the file and quickly afterwards the ProcessKiller comes up in Logcat and then the app crashes, I assume that ProcessKiller kills my app because of the open file. But what ProcessKiller is I cannot find more information. Or if I should close the output stream in another fashion I don't know as well.</p>
  
  <p>If somebody has a suggestion, please share it. Thanks a lot!
  Cheers</p>