bug 634375 - kill plugin-container if it's in the way r=dougt a=blocking-fennec
authorBrad Lassey <blassey@mozilla.com>
Tue, 22 Feb 2011 13:38:13 -0500
changeset 62928 7e2360c48bbac8ad5fd846e9ae9684d6f429318f
parent 62927 a3f202325d27cdd88c66d82fa17b468ff6898eae
child 62929 59beb0363569ebbce51350a82c82f2950c7e0773
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersdougt, blocking-fennec
bugs634375
milestone2.0b12pre
bug 634375 - kill plugin-container if it's in the way r=dougt a=blocking-fennec
embedding/android/GeckoApp.java
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -450,16 +450,18 @@ abstract public class GeckoApp
                                             zip.getName());
 
         File outFile = new File(sGREDir, name);
         if (outFile.exists() &&
             outFile.lastModified() == fileEntry.getTime() &&
             outFile.length() == fileEntry.getSize())
             return;
 
+        killAnyZombies();
+
         File dir = outFile.getParentFile();
         if (!outFile.exists())
             dir.mkdirs();
 
         InputStream fileStream;
         fileStream = zip.getInputStream(fileEntry);
 
         OutputStream outStream = new FileOutputStream(outFile);
@@ -469,16 +471,37 @@ abstract public class GeckoApp
             outStream.write(buf, 0, read);
         }
 
         fileStream.close();
         outStream.close();
         outFile.setLastModified(fileEntry.getTime());
     }
 
+    boolean haveKilledZombies = false;
+
+    void killAnyZombies() {
+        if (haveKilledZombies)
+            return;
+        haveKilledZombies = true;
+        File proc = new File("/proc");
+        File[] files = proc.listFiles();
+        for (int i = 0; i < files.length; i++) {
+            File p = files[i];
+            File pEnv = new File(p, "environ");
+            if (pEnv.canRead() && !p.getName().equals("self")) {
+                int pid = Integer.parseInt(p.getName());
+                if (pid != android.os.Process.myPid()) {
+                    Log.i("GeckoProcs", "gonna kill pid: " + p.getName());
+                    android.os.Process.killProcess(pid);
+                }
+            }
+        }
+    }
+
     public void addEnvToIntent(Intent intent) {
         Map<String,String> envMap = System.getenv();
         Set<Map.Entry<String,String>> envSet = envMap.entrySet();
         Iterator<Map.Entry<String,String>> envIter = envSet.iterator();
         StringBuffer envstr = new StringBuffer();
         int c = 0;
         while (envIter.hasNext()) {
             Map.Entry<String,String> entry = envIter.next();