From 80ef448f8c6774cc49c0b54cb48f3cf156fe8471 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 19 Sep 2008 16:09:06 +0000 Subject: [PATCH] list service pid --- .../java/src/org/hyperic/sigar/win32/Service.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bindings/java/src/org/hyperic/sigar/win32/Service.java b/bindings/java/src/org/hyperic/sigar/win32/Service.java index b71bdd94..4cf685db 100644 --- a/bindings/java/src/org/hyperic/sigar/win32/Service.java +++ b/bindings/java/src/org/hyperic/sigar/win32/Service.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; import org.hyperic.sigar.Sigar; +import org.hyperic.sigar.SigarException; public class Service extends Win32 { // Service State @@ -388,6 +389,18 @@ public class Service extends Win32 { public void list(PrintStream out) throws Win32Exception { getConfig().list(out); 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 {