Ignore:
Timestamp:
2017-05-08T21:18:21+12:00 (7 years ago)
Author:
ak19
Message:

GS3 source code now updated to use SafeProcess instead of Process (calling Runtime.exec() directly). The use of SafeProcess in RunTarget and BrowserLauncher has been tested on Linux. GDBMWrapper, MapRetrieve and admin/guiext's Command.java are not tested. For GDBMWrapper, because it's in a bit of code that works with txtgz databases. MapRetrive.java and Command.java are untested because I don't know how to test them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/util/BrowserLauncher.java

    r22085 r31665  
    77import org.greenstone.server.BaseProperty;
    88import org.greenstone.util.Misc;
     9import org.greenstone.util.SafeProcess;
    910import org.apache.log4j.*;
    1011
     
    5051         // we try to look for a browser
    5152        for (int i=0; i<default_browsers.length; i++) {
    52         if (isAvailable(default_browsers[i])) {
     53        if (SafeProcess.isAvailable(default_browsers[i])) {
    5354            this.command = default_browsers[i] + " %1";
    5455            break;
     
    6061    }
    6162
     63    // Replaced by SafeProcess.isAvailable(program)
     64    /*
    6265    protected boolean isAvailable(String program) {
    6366    try {
     
    7679        return false;
    7780    }
    78     }
     81    }*/
    7982
    8083    public  int getBrowserState(){
     
    100103        logger.info(new_command);
    101104        Runtime rt = Runtime.getRuntime();
    102         Process process = rt.exec(new_command);
     105        //Process process = rt.exec(new_command);
    103106                state = LAUNCHSUCCESS;
    104         exitCode = process.waitFor();
     107        //exitCode = process.waitFor();
     108        SafeProcess process = new SafeProcess(new_command);
     109        exitCode = process.runProcess();
     110        process = null;
    105111        logger.info("ExitCode:" + exitCode);             
    106112        if (exitCode != 0) { // if Netscape or mozilla was not open
    107113            logger.info("couldn't do remote, trying original command");
    108114                    logger.info(this.command);
    109             process = rt.exec(this.command); // try the original command
     115            //process = rt.exec(this.command); // try the original command
    110116                    state = LAUNCHSUCCESS;
    111117            //for some reason the following part is not executed sometimes.
    112                     exitCode = process.waitFor();
     118                    //exitCode = process.waitFor();
     119            process = new SafeProcess(this.command);
     120            exitCode = process.runProcess();
     121            process = null;
    113122        }
    114123        } else {
    115124        logger.info(this.command);
    116125                Runtime rt = Runtime.getRuntime();
    117         Process process = rt.exec(this.command);
     126        //Process process = rt.exec(this.command);
    118127                state = LAUNCHSUCCESS;
    119128                //for some reason the following part is not executed sometimes.
    120                 exitCode = process.waitFor();
     129                //exitCode = process.waitFor();
     130        SafeProcess process = new SafeProcess(this.command);
     131        exitCode = process.runProcess();
    121132        }
    122133
Note: See TracChangeset for help on using the changeset viewer.