diff --git a/solaris/Platform.c b/solaris/Platform.c index ff2e5c61..cf85a4c8 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -151,24 +151,22 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) { } int Platform_getMaxPid() { - kstat_ctl_t* kc = NULL; - kstat_t* kshandle = NULL; - kvar_t* ksvar = NULL; int vproc = 32778; // Reasonable Solaris default - kc = kstat_open(); - if (kc != NULL) { - kshandle = kstat_lookup(kc, "unix", 0, "var"); - } - if (kshandle != NULL) { - kstat_read(kc, kshandle, NULL); - } - ksvar = kshandle->ks_data; - if (ksvar->v_proc > 0 ) { - vproc = ksvar->v_proc; - } + + kstat_ctl_t* kc = kstat_open(); if (kc != NULL) { + kstat_t* kshandle = kstat_lookup(kc, "unix", 0, "var"); + if (kshandle != NULL) { + kstat_read(kc, kshandle, NULL); + + kvar_t* ksvar = kshandle->ks_data; + if (ksvar && ksvar->v_proc > 0) { + vproc = ksvar->v_proc; + } + } kstat_close(kc); } + return vproc; }