Changeset 31664 for main


Ignore:
Timestamp:
2017-05-08T18:32:28+12:00 (7 years ago)
Author:
ak19
Message:

Tabbing for emacs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/util/SafeProcess.java

    r31651 r31664  
    5454    private String inputStr = null;
    5555    private Process process = null;
    56     private boolean forciblyTerminateProcess = false;
     56    private boolean forciblyTerminateProcess = false;
    5757   
    5858    // output from running SafeProcess.runProcess()
     
    135135       
    136136        // http://stackoverflow.com/questions/5283444/convert-array-of-strings-into-a-string-in-java
    137         //log("SafeProcess running:" + Arrays.toString(command_args));
    138         StringBuffer cmdDisplay = new StringBuffer();
    139         for(int i = 0; i < command_args.length; i++) {
    140             cmdDisplay.append(" ").append(command_args[i]);
    141         }
    142         log("SafeProcess running: [" + cmdDisplay + "]");
    143         cmdDisplay = null; // let the GC have it   
    144        
     137        //log("SafeProcess running:" + Arrays.toString(command_args));
     138        StringBuffer cmdDisplay = new StringBuffer();
     139        for(int i = 0; i < command_args.length; i++) {
     140        cmdDisplay.append(" ").append(command_args[i]);
     141        }
     142        log("SafeProcess running: [" + cmdDisplay + "]");
     143        cmdDisplay = null; // let the GC have it   
     144       
    145145       
    146146        if(this.envp == null) {
     
    157157        }
    158158        }
    159     }   
     159    }
    160160
    161161    return prcs;
     
    167167                   SafeProcess.InputStreamGobbler errorGobbler)
    168168    throws IOException, InterruptedException
    169     {   
     169    {
    170170    // kick off the stream gobblers
    171171    inputGobbler.start();
     
    203203        errorGobbler.interrupt();
    204204        outputGobbler.interrupt();
    205        
    206         // Since we have been cancelled (InterruptedException), or on any Exception, we need
    207         // to forcibly terminate process eventually after the finally code first waits for each worker thread
    208         // to die off. Don't set process=null until after we've forcibly terminated it if needs be.
    209         this.forciblyTerminateProcess = true;
     205       
     206        // Since we have been cancelled (InterruptedException), or on any Exception, we need
     207        // to forcibly terminate process eventually after the finally code first waits for each worker thread
     208        // to die off. Don't set process=null until after we've forcibly terminated it if needs be.
     209        this.forciblyTerminateProcess = true;
    210210       
    211211        // even after the interrupts, we want to proceed to calling join() on all the worker threads
     
    252252    // Run a very basic process: with no reading from or writing to the Process' iostreams,
    253253    // this just execs the process and waits for it to return.
    254     // Don't call this method but the zero-argument runProcess() instead if your process will
    255     // output stuff to its stderr and stdout streams but you don't need to monitory these.
    256     // Because, as per a comment in GLI's GS3ServerThread.java,
    257     // in Java 6, it wil block if you don't handle a process' streams when the process is
    258     // outputting something. (Java 7+ won't block if you don't bother to handle the output streams)
     254    // Don't call this method but the zero-argument runProcess() instead if your process will
     255    // output stuff to its stderr and stdout streams but you don't need to monitory these.
     256    // Because, as per a comment in GLI's GS3ServerThread.java,
     257    // in Java 6, it wil block if you don't handle a process' streams when the process is
     258    // outputting something. (Java 7+ won't block if you don't bother to handle the output streams)
    259259    public int runBasicProcess() {
    260260    try {
    261         this.forciblyTerminateProcess = true;
     261        this.forciblyTerminateProcess = true;
    262262       
    263263        // 1. create the process
     
    266266        this.exitValue = process.waitFor();
    267267
    268         this.forciblyTerminateProcess = false;
     268        this.forciblyTerminateProcess = false;
    269269    } catch(IOException ioe) {     
    270270       
     
    275275        }
    276276    } catch(InterruptedException ie) {
    277        
     277
    278278        if(exceptionHandler != null) {
    279279        exceptionHandler.gotException(ie);
     
    288288        destroyProcess(process); // see runProcess() below     
    289289        }
    290         process = null;
    291         this.forciblyTerminateProcess = false; // reset
     290        process = null;
     291        this.forciblyTerminateProcess = false; // reset
    292292    }
    293293    return this.exitValue;
     
    311311
    312312    try {
    313         this.forciblyTerminateProcess = false;
     313        this.forciblyTerminateProcess = false;
    314314       
    315315        // 1. get the Process object
     
    351351       
    352352    } catch(IOException ioe) {
    353         this.forciblyTerminateProcess = true;
     353        this.forciblyTerminateProcess = true;
    354354
    355355        if(exceptionHandler != null) {
     
    381381        }
    382382        process = null;
    383         this.forciblyTerminateProcess = false; // reset
     383        this.forciblyTerminateProcess = false; // reset
    384384    }
    385385   
     
    394394
    395395    try {
    396         this.forciblyTerminateProcess = false;
     396        this.forciblyTerminateProcess = false;
    397397       
    398398        // 1. get the Process object
     
    428428       
    429429    } catch(IOException ioe) {
    430         this.forciblyTerminateProcess = true;
     430        this.forciblyTerminateProcess = true;
    431431       
    432432        if(exceptionHandler != null) {
     
    468468        log("*** Have called process.destroy 1");
    469469        }
    470         process = null;
    471         this.forciblyTerminateProcess = false; //reset     
     470        process = null;
     471        this.forciblyTerminateProcess = false; //reset     
    472472    }
    473473   
     
    839839   
    840840    public InputStreamGobbler(InputStream is, boolean split_newlines)
    841     {   
     841    {
    842842    this(); // sets thread name
    843843    this.is = is;
Note: See TracChangeset for help on using the changeset viewer.