<commit_before>package org.apache.cordova.plugin;

import android.content.Context;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ShellExec extends CordovaPlugin {

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

        if (action.equals("exec")) {
                Process p;
                StringBuffer output = new StringBuffer();
                int exitStatus = 100;
                try {
                        p = Runtime.getRuntime().exec((String) args.get(0));
                        BufferedReader reader = new BufferedReader(
                                new InputStreamReader(p.getInputStream()));
                        String line = "";
                        while ((line = reader.readLine()) != null) {
                                output.append(line + "\n");
                                p.waitFor();
                        }
                        exitStatus = p.exitValue();
                }
                catch (IOException e) {
                        e.printStackTrace();
                } catch (InterruptedException e) {
                        e.printStackTrace();
                }

                JSONObject json = new JSONObject();
                json.put("exitStatus", exitStatus);
                json.put("output", output.toString());
                callbackContext.success(json);
                return true;
        }
        return false;
}

}<commit_msg>fix 'Process has not yet terminated:'<commit_after>package org.apache.cordova.plugin;

import android.content.Context;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ShellExec extends CordovaPlugin {

@Override
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {

        if (action.equals("exec")) {
                final String cmd = (String) args.get(0);
                cordova.getThreadPool().execute(new Runnable() {
                        public void run() {
                                Process p;
                                StringBuffer output = new StringBuffer();
                                int exitStatus = 100;
                                try {
                                        p = Runtime.getRuntime().exec(cmd);
                                        BufferedReader reader = new BufferedReader( new InputStreamReader(p.getInputStream()) );
                                        String line = "";
                                        while ((line = reader.readLine()) != null) {
                                                output.append(line + "\n");
                                                //p.waitFor();
                                        }
                                        //exitStatus = p.exitValue();
                                        exitStatus = p.waitFor();
                                }
                                catch (IOException e) {
                                        e.printStackTrace();
                                } catch (InterruptedException e) {
                                        e.printStackTrace();
                                }

                                try {
                                        JSONObject json = new JSONObject();
                                        json.put("exitStatus", exitStatus);
                                        json.put("output", output.toString());
                                        callbackContext.success(json);
                                }
                                catch(JSONException e){
                                        e.printStackTrace();
                                        callbackContext.success();
                                }
                        }
                });
                return true;
        }
        return false;
}

}
{'fraction_non_alphanumeric': 0.08352402745995423, 'fraction_numerical': 0.0018306636155606408, 'mean_word_length': 1.0834127740705435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 23, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6335757', 'n_tokens_mistral': 895, 'n_tokens_neox': 841, 'n_words': 200}