list service pid

This commit is contained in:
Doug MacEachern 2008-09-19 16:09:06 +00:00
parent 26f2977533
commit 80ef448f8c
1 changed files with 13 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hyperic.sigar.Sigar; import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
public class Service extends Win32 { public class Service extends Win32 {
// Service State // Service State
@ -388,6 +389,18 @@ public class Service extends Win32 {
public void list(PrintStream out) throws Win32Exception { public void list(PrintStream out) throws Win32Exception {
getConfig().list(out); getConfig().list(out);
out.println("status........[" + getStatusString() + "]"); out.println("status........[" + getStatusString() + "]");
if (getStatus() != SERVICE_RUNNING) {
return;
}
Sigar sigar = new Sigar();
try {
long pid = sigar.getServicePid(getConfig().getName());
out.println("pid...........[" + pid + "]");
} catch (SigarException e) {
} finally {
sigar.close();
}
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {