Ignore:
Timestamp:
2017-05-04T20:32:17+12:00 (7 years ago)
Author:
ak19
Message:
  1. Moved isAvailable(program) into SafeProcess.java from FileAssociationManager.java. 2. SafeProcess.java now successfully terminates any child processes launched on Windows too because of the addition of new methods. But the real solution may need to be in Perl, especially if using mobile windows OS where the system tools currently being used may not be present. 4. Adding JNA jar files, jna.jar and jna-platform.jar of version 4.1.0 (2013), to gli's lib. These are needed to get the PID of a running process on Windows. 5. Need to tidy up code, need to check linux is not affected by platform specific import statements used by Windows, need to make the process termination recursive (not just children, but all descendants need to be killed on destroyProcess(p). Rather than wmic delete or taskkill or tskill, can use the linked Java code Processes.java which is dependent on JNA.
File:
1 edited

Legend:

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

    r31637 r31646  
    117117        String [] browsers = new String [] {"mozilla", "netscape", "firefox"};
    118118        for (int i=0; i<browsers.length; i++) {
    119         if (isAvailable(browsers[i])) {
     119        if (SafeProcess.isAvailable(browsers[i])) {
    120120            command = browsers[i]+ " %1";
    121121            break;
     
    351351    }
    352352
    353 
    354     protected boolean isAvailable(String program) {
    355     try {
    356         // `which bla` does nothing, prompt is returned
    357         // `which grep` returns a line of output with the path to grep
    358         SafeProcess prcs = new SafeProcess("which " + program);
    359         prcs.runProcess();
    360         String output = prcs.getStdOutput();
    361         if(output.equals("")) {
    362         return false;
    363         }
    364         //System.err.println("*** 'which " + program + "' returned: " + output);
    365         return true;
    366     } catch (Exception exc) {
    367         return false;
    368     }
    369     }
    370353}
Note: See TracChangeset for help on using the changeset viewer.