diff --git a/bindings/java/src/jni/generate.pl b/bindings/java/src/jni/generate.pl index 881f75d1..ab00b683 100644 --- a/bindings/java/src/jni/generate.pl +++ b/bindings/java/src/jni/generate.pl @@ -803,9 +803,6 @@ my %classes = ( }, ], ResourceLimit => [ - { - name => 'unlimited', - }, { name => 'cpu_cur', }, @@ -1143,6 +1140,9 @@ EOF (this.free / 1024) + "K free, " + (this.shared / 1024) + "K shrd"; } +EOF + ResourceLimit => <<'EOF', + public static native long INFINITY(); EOF Swap => <<'EOF', public String toString() { diff --git a/bindings/java/src/jni/javasigar.c b/bindings/java/src/jni/javasigar.c index 9e5a143d..21e5218f 100644 --- a/bindings/java/src/jni/javasigar.c +++ b/bindings/java/src/jni/javasigar.c @@ -1248,3 +1248,14 @@ JNIEXPORT jlong SIGAR_JNI(Sigar_getServicePid) return 0; #endif } + +JNIEXPORT jlong SIGAR_JNI(ResourceLimit_INFINITY) +(JNIEnv *env, jclass cls) +{ +#ifdef WIN32 + return 0x7fffffff; +#else +#include + return RLIM_INFINITY; +#endif +} diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Ulimit.java b/bindings/java/src/net/hyperic/sigar/cmd/Ulimit.java index a1c6eb7b..707640a1 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Ulimit.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Ulimit.java @@ -20,8 +20,8 @@ public class Ulimit extends SigarCommandBase { return "Display system resource limits"; } - private static String format(ResourceLimit rlimit, long val) { - if (val == rlimit.getUnlimited()) { + private static String format(long val) { + if (val == ResourceLimit.INFINITY()) { return "unlimited"; } else { @@ -33,23 +33,23 @@ public class Ulimit extends SigarCommandBase { ResourceLimit rlimit = this.sigar.getResourceLimit(); println("core file size......." + - format(rlimit, rlimit.getCoreCur())); + format(rlimit.getCoreCur())); println("data seg size........" + - format(rlimit, rlimit.getDataCur())); + format(rlimit.getDataCur())); println("file size............" + - format(rlimit, rlimit.getFileSizeCur())); + format(rlimit.getFileSizeCur())); println("max memory size......" + - format(rlimit, rlimit.getMemoryCur())); + format(rlimit.getMemoryCur())); println("open files..........." + - format(rlimit, rlimit.getOpenFilesCur())); + format(rlimit.getOpenFilesCur())); println("stack size..........." + - format(rlimit, rlimit.getStackCur())); + format(rlimit.getStackCur())); println("cpu time............." + - format(rlimit, rlimit.getCpuCur())); + format(rlimit.getCpuCur())); println("max user processes..." + - format(rlimit, rlimit.getProcessesCur())); + format(rlimit.getProcessesCur())); println("virual memory........" + - format(rlimit, rlimit.getVirtualMemoryCur())); + format(rlimit.getVirtualMemoryCur())); } public static void main(String[] args) throws Exception { diff --git a/include/sigar.h b/include/sigar.h index 66ed3781..9b6a80d6 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -182,8 +182,6 @@ typedef struct { sigar_uint64_t open_files_cur, open_files_max; /* RLIMIT_AS */ sigar_uint64_t virtual_memory_cur, virtual_memory_max; - /* RLIM_INFINITY */ - sigar_uint64_t unlimited; } sigar_resource_limit_t; SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar, diff --git a/src/sigar.c b/src/sigar.c index 1ed5e86c..c64de8d5 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -754,7 +754,7 @@ SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar, sigar_resource_limit_t *rlimit) { MEMORY_BASIC_INFORMATION meminfo; - memset(rlimit, -1, sizeof(*rlimit)); + memset(rlimit, 0x7fffffff, sizeof(*rlimit)); if (VirtualQuery((LPCVOID)&meminfo, &meminfo, sizeof(meminfo))) { rlimit->stack_cur = @@ -971,8 +971,6 @@ int sigar_resource_limit_get(sigar_t *sigar, { int i; - rlimit->unlimited = RLIM_INFINITY; - for (i=0; sigar_rlimits[i].resource != -1; i++) { struct rlimit rl; rlimit_field_t *r = &sigar_rlimits[i];