static boolean canExecuteUnixPs() { return canExecuteLocalUnixPs() || canExecuteStandardUnixPs(); }
private static boolean canUseNewPingMechanism( PpidChecker pluginProcessChecker ) { return pluginProcessChecker != null && pluginProcessChecker.canUse(); }
void shutdown() { pingScheduler.shutdown(); if ( pluginProcessChecker != null ) { pluginProcessChecker.destroyActiveCommands(); } }
@Override ProcessInfo consumeLine( String line, ProcessInfo previousOutputLine ) { if ( previousOutputLine.isInvalid() ) { Matcher matcher = UNIX_CMD_OUT_PATTERN.matcher( line ); if ( matcher.matches() ) { long pidUptime = fromDays( matcher ) + fromHours( matcher ) + fromMinutes( matcher ) + fromSeconds( matcher ); return unixProcessInfo( ppid, pidUptime ); } } return previousOutputLine; } };
boolean isProcessAlive() if ( !canUse() ) parentProcessInfo = windows(); checkProcessInfo(); parentProcessInfo = unix(); checkProcessInfo();
@Override public void run() { try { if ( pingMechanism.pluginProcessChecker.canUse() && !pingMechanism.pluginProcessChecker.isProcessAlive() && !pingMechanism.pingScheduler.isShutdown() ) { DumpErrorSingleton.getSingleton() .dumpText( "Killing self fork JVM. Maven process died." ); kill(); } } catch ( RuntimeException e ) { DumpErrorSingleton.getSingleton() .dumpException( e, "System.exit() or native command error interrupted process checker." ); } } };
private static String unixPathToPS() { return canExecuteLocalUnixPs() ? "/usr/bin/ps" : "/bin/ps"; }
boolean canUse() { final ProcessInfo ppi = parentProcessInfo; return ppi == null ? IS_OS_WINDOWS || IS_OS_UNIX && canExecuteUnixPs() : ppi.canUse(); }
private PingScheduler listenToShutdownCommands( Long ppid ) { commandReader.addShutdownListener( createExitHandler() ); AtomicBoolean pingDone = new AtomicBoolean( true ); commandReader.addNoopListener( createPingHandler( pingDone ) ); PingScheduler pingMechanisms = new PingScheduler( createPingScheduler(), ppid == null ? null : new PpidChecker( ppid ) ); if ( pingMechanisms.pluginProcessChecker != null ) { Runnable checkerJob = processCheckerJob( pingMechanisms ); pingMechanisms.pingScheduler.scheduleWithFixedDelay( checkerJob, 0L, 1L, SECONDS ); } Runnable pingJob = createPingJob( pingDone, pingMechanisms.pluginProcessChecker ); pingMechanisms.pingScheduler.scheduleAtFixedRate( pingJob, 0L, PING_TIMEOUT_IN_SECONDS, SECONDS ); return pingMechanisms; }