try {
System.loadLibrary("jvminfoutil");
pidLoggingEnabled = true;
} catch (Throwable t) {
// Log the fact that PID logging remains disabled
// which means --kill commands will not work.
if (debug && !pidLoggingEnabled) {
_logger.log(Level.WARNING, localStrings.getLocalString(
"utility.no.pid.logging", "Process ID of this Java Virtual" +
"Machine will not be logged. Consequently the --kill option " +
"in Asadmin CLI commands such as stop-domain, stop-instance," +
" stop-node-agent and stop-cluster will be disabled."));
}
}
PrintStream ps = null;
File pidFile = new File(pidFileName);
try {
if (debug) System.out.println("PID = " + getPid());
if (debug) System.out.println("PID FILENAME = " + pidFileName);
ps = new PrintStream(pidFile);
if (pidLoggingEnabled)
ps.println("" + getPid());
else ps.println("-1"); //dos.writeInt(-1); // clients of the pid file interprete -1
// as "NO_PROCESS should be killed".
ps.flush();
} catch (Throwable ex) {
// Could not update the pid file with latest info.
// ignore. Because the initiator VMs for stop-xxx commands
// will check for the timestamp of this file and the admsn
} finally {
try {
if (ps != null) ps.close();
} catch (Exception ex) {
//ignore
}
// Bugfix suggested by Abhijit Kumar
// this will guarantee that once this process is dead - there won't
// be a file with the old invalid pid lying around.
pidFile.deleteOnExit();
}