Changeset 31643 for main


Ignore:
Timestamp:
05/02/17 20:33:29 (4 years ago)
Author:
ak19
Message:

Taskkill does not seem to be a route, but adding in code that works, but will kill any running perl on Windows, not just specific perl processes launched by GS.

File:
1 edited

Legend:

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

    r31642 r31643  
    129129        }
    130130        }
    131     }
     131    }   
    132132
    133133    return prcs;
     
    253253
    254254        if( this.forciblyTerminateProcess ) {
    255         process.destroy(); // see runProcess() below       
     255        process.destroy(); // see runProcess() below
     256        //killAnyPerl();
    256257        }
    257258        process = null;
     
    345346        log("*** Going to call process.destroy 2");
    346347        process.destroy();
     348        //killAnyPerl();
    347349        log("*** Have called process.destroy 2");
    348350        }
     
    433435        log("*** Going to call process.destroy 1");
    434436        process.destroy();
     437        //killAnyPerl();
    435438        log("*** Have called process.destroy 1");
    436439        }
     
    442445    }
    443446
    444 
     447// stackoverflow.com/questions/1835885/send-ctrl-c-to-process-open-by-java 
     448// (Taskkill command can kill all running perl. But what if we kill perl instances not launched by GS?)
     449// stackoverflow.com/questions/912889/how-to-send-interrupt-key-sequence-to-a-java-process
     450// Searching for: "forcibly terminate external process launched by Java on Windows"
     451static void killAnyPerl() {
     452    if(!Utility.isWindows()) return;
     453   
     454    // only on Windows do we need to still kill perl despite process.destroy()
     455    try{
     456        Runtime.getRuntime().exec("taskkill /f /im perl.exe");     
     457    } catch(Exception e) {
     458        log("@@@ Exception attempting to stop perl " + e.getMessage(), e);     
     459    }
     460}
     461   
    445462//******************** Inner class and interface definitions ********************//
    446463// Static inner classes can be instantiated without having to instantiate an object of the outer class first
Note: See TracChangeset for help on using the changeset viewer.