Ignore:
Timestamp:
2017-05-31T18:05:11+12:00 (7 years ago)
Author:
ak19
Message:

Two more instances in GLI's Gatherer.java were using Java's Process instead of going through SafeProcess. I had a note in the tickets about this, but it was obscured by being an item in my todo list that was ticked off, because I hadn't originally intended to change these 2 instances to use SafeProcess, because SafeProcess didn't have a cancel feature back then. With the recent addition of the cancel feature, the changes became straightforward. Both remaining instances in Gatherer have been changed to use SafeProcess and it's tested on Linux. Updated the SafeProcess README.

File:
1 edited

Legend:

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

    r31670 r31718  
    14561456    static private class ExternalApplication
    14571457    extends Thread {
    1458         private Process process = null;
     1458        private SafeProcess process = null;
    14591459        /** The initial command string given to this sub-process. */
    14601460        private String command = null;
     
    15151515                    }
    15161516                    DebugStream.println("Running " + whole_command.toString());
    1517                     Runtime rt = Runtime.getRuntime();
    1518                     process = rt.exec(commands);
    1519                     process.waitFor();
     1517                    process = new SafeProcess(commands);
    15201518                }
    15211519                else {
    15221520                    DebugStream.println("Running " + command);
    1523                     Runtime rt = Runtime.getRuntime();
    1524                     process = rt.exec(command);
    1525                     process.waitFor();
    1526                 }
     1521                    process = new SafeProcess(command);
     1522                }
     1523                process.runProcess();
    15271524            }
    15281525            catch (Exception exception) {
     
    15481545        public void stopExternalApplication() {
    15491546            if(process != null) {
    1550                 process.destroy();
     1547                SafeProcess.log("*** stopExternalApplication called.");
     1548                process.cancelRunningProcess();
    15511549            }
    15521550        }
     
    15551553    static private class BrowserApplication
    15561554    extends Thread {
    1557         private Process process = null;
     1555        private SafeProcess process = null;
    15581556        /** The initial command string given to this sub-process. */
    15591557        private String command = null;
     
    15951593                    printArray(new_commands);
    15961594
    1597                     Runtime rt = Runtime.getRuntime();
    1598                     process = rt.exec(new_commands);
    1599                     int exitCode = process.waitFor();
     1595                    process = new SafeProcess(new_commands);
     1596                    int exitCode = process.runProcess();
    16001597                    if (exitCode != 0) { // if Netscape or mozilla was not open
    16011598                        DebugStream.println("couldn't do remote, trying original command");
    16021599                        printArray(commands);
    1603                         process = rt.exec(commands); // try the original command
     1600                        process = null;
     1601                        process = new SafeProcess(commands); // try the original command
     1602                        process.runProcess();
    16041603                    }
    16051604                } else {
     
    16111610                    }
    16121611                    DebugStream.println("Running " + whole_command.toString());
    1613                     Runtime rt = Runtime.getRuntime();
    1614                     process = rt.exec(commands);
    1615                     process.waitFor();
     1612                    process = new SafeProcess(commands);
     1613                    process.runProcess();
    16161614                }
    16171615            }
     
    16351633        public void stopBrowserApplication() {
    16361634            if(process != null) {
    1637                 process.destroy();
     1635                SafeProcess.log("*** stopBrowserApplication called.");
     1636                process.cancelRunningProcess();
    16381637            }
    16391638        }
Note: See TracChangeset for help on using the changeset viewer.