BSD-Process
view release on metacpan or search on metacpan
argsv = newSVpvn(*argv, len);
while (*++argv) {
sv_catpvn(argsv, " ", 1);
sv_catpvn(argsv, *argv, strlen(*argv));
}
}
else {
/* sometimes the process args may be unavailable; when this happens the name
* of the executable in brackets is returned, similar to the ps program.
*/
argsv = newSVpvn("[", 1);
sv_catpvn(argsv, kp->COMM_FIELD, strlen(kp->COMM_FIELD));
sv_catpvn(argsv, "]", 1);
}
hv_store(h, "args", 4, argsv, 0);
if (kd) {
kvm_close(kd);
}
/* deal with groups array */
for (g = 0; g < kp->ki_ngroups; ++g) {
if (resolve && (gr = getgrgid(kp->ki_groups[g]))) {
av_push(grlist, newSVpvn(gr->gr_name, strlen(gr->gr_name)));
}
else {
av_push(grlist, newSViv(kp->ki_groups[g]));
}
}
#endif
hv_store(h, "groups", 6, newRV((SV *)grlist), 0);
hv_store(h, "ngroups", 7, newSViv(NO_FREEBSD_4x(kp->ki_ngroups)), 0);
hv_store(h, "size", 4, newSViv(NO_FREEBSD_4x(kp->ki_size)), 0);
hv_store(h, "dsize", 5, newSViv(NO_FREEBSD_4x(kp->ki_dsize)), 0);
hv_store(h, "ssize", 5, newSViv(NO_FREEBSD_4x(kp->ki_ssize)), 0);
hv_store(h, "start", 5, newSVnv(NO_FREEBSD_4x(TIME_FRAC(kp->ki_start))), 0);
hv_store(h, "childtime", 9, newSVnv(NO_FREEBSD_4x(TIME_FRAC(kp->ki_childtime))), 0);
hv_store(h, "advlock", 7, newSViv(NO_FREEBSD_4x(P_FLAG(P_ADVLOCK))), 0);
hv_store(h, "controlt", 8, newSViv(NO_FREEBSD_4x(P_FLAG(P_CONTROLT))), 0);
hv_store(h, "kthread", 7, newSViv(NO_FREEBSD_4x(P_FLAG(P_KTHREAD))), 0);
#if __FreeBSD_version < 802501
hv_store(h, "noload", 6, newSViv(NO_FREEBSD_4x(P_FLAG(P_NOLOAD))), 0);
#endif
hv_store(h, "ppwait", 6, newSViv(NO_FREEBSD_4x(P_FLAG(P_PPWAIT))), 0);
hv_store(h, "profil", 6, newSViv(NO_FREEBSD_4x(P_FLAG(P_PROFIL))), 0);
hv_store(h, "stopprof", 8, newSViv(NO_FREEBSD_4x(P_FLAG(P_STOPPROF))), 0);
hv_store(h, "sugid", 5, newSViv(NO_FREEBSD_4x(P_FLAG(P_SUGID))), 0);
hv_store(h, "system", 6, newSViv(NO_FREEBSD_4x(P_FLAG(P_SYSTEM))), 0);
hv_store(h, "single_exit", 11, newSViv(NO_FREEBSD_4x(P_FLAG(P_SINGLE_EXIT))), 0);
hv_store(h, "traced", 6, newSViv(NO_FREEBSD_4x(P_FLAG(P_TRACED))), 0);
hv_store(h, "waited", 6, newSViv(NO_FREEBSD_4x(P_FLAG(P_WAITED))), 0);
hv_store(h, "wexit", 5, newSViv(NO_FREEBSD_4x(P_FLAG(P_WEXIT))), 0);
hv_store(h, "exec", 4, newSViv(NO_FREEBSD_4x(P_FLAG(P_EXEC))), 0);
hv_store(h, "hadthreads", 10, newSViv(NO_FREEBSD_5x(P_FLAG(P_HADTHREADS))), 0);
hv_store(h, "kiflag", 6, newSViv(NO_FREEBSD_4x(kp->ki_kiflag)), 0);
hv_store(h, "locked", 6, newSViv(NO_FREEBSD_4x(KI_FLAG(KI_LOCKBLOCK))), 0);
hv_store(h, "isctty", 6, newSViv(NO_FREEBSD_4x(KI_FLAG(KI_CTTY))), 0);
hv_store(h, "issleader", 9, newSViv(NO_FREEBSD_4x(KI_FLAG(KI_SLEADER))), 0);
hv_store(h, "stat", 4, newSViv(NO_FREEBSD_4x((int)kp->ki_stat)), 0);
hv_store(h, "stat_1", 6, newSViv(NO_FREEBSD_4x((int)kp->ki_stat == 1 ? 1 : 0)), 0);
hv_store(h, "stat_2", 6, newSViv(NO_FREEBSD_4x((int)kp->ki_stat == 2 ? 1 : 0)), 0);
hv_store(h, "stat_3", 6, newSViv(NO_FREEBSD_4x((int)kp->ki_stat == 3 ? 1 : 0)), 0);
hv_store(h, "stat_4", 6, newSViv(NO_FREEBSD_4x((int)kp->ki_stat == 4 ? 1 : 0)), 0);
hv_store(h, "stat_5", 6, newSViv(NO_FREEBSD_4x((int)kp->ki_stat == 5 ? 1 : 0)), 0);
hv_store(h, "stat_6", 6, newSViv(NO_FREEBSD_4x((int)kp->ki_stat == 6 ? 1 : 0)), 0);
hv_store(h, "stat_7", 6, newSViv(NO_FREEBSD_4x((int)kp->ki_stat == 7 ? 1 : 0)), 0);
hv_store(h, "ocomm", 5, newSVpv(NO_FREEBSD_4x_pv(kp->ki_ocomm), 0), 0);
hv_store(h, "lockname", 8, newSVpv(NO_FREEBSD_4x_pv(kp->ki_lockname), 0), 0);
hv_store(h, "pri_class", 9, newSViv(NO_FREEBSD_4x(kp->ki_pri.pri_class)), 0);
hv_store(h, "pri_level", 9, newSViv(NO_FREEBSD_4x(kp->ki_pri.pri_level)), 0);
hv_store(h, "pri_native", 10, newSViv(NO_FREEBSD_4x(kp->ki_pri.pri_native)), 0);
hv_store(h, "pri_user", 8, newSViv(NO_FREEBSD_4x(kp->ki_pri.pri_user)), 0);
NO_FREEBSD_4x(rp = &kp->ki_rusage);
hv_store(h, "utime", 5, newSVnv(NO_FREEBSD_4x(TIME_FRAC(rp->ru_utime))), 0);
hv_store(h, "stime", 5, newSVnv(NO_FREEBSD_4x(TIME_FRAC(rp->ru_stime))), 0);
hv_store(h, "time", 4, newSVnv(NO_FREEBSD_4x(
TIME_FRAC(rp->ru_utime)+TIME_FRAC(rp->ru_stime))), 0);
hv_store(h, "maxrss", 6, newSVnv(NO_FREEBSD_4x(rp->ru_maxrss)), 0);
hv_store(h, "ixrss", 5, newSVnv(NO_FREEBSD_4x(rp->ru_ixrss)), 0);
hv_store(h, "idrss", 5, newSVnv(NO_FREEBSD_4x(rp->ru_idrss)), 0);
hv_store(h, "isrss", 5, newSVnv(NO_FREEBSD_4x(rp->ru_isrss)), 0);
hv_store(h, "minflt", 6, newSVnv(NO_FREEBSD_4x(rp->ru_minflt)), 0);
hv_store(h, "majflt", 6, newSVnv(NO_FREEBSD_4x(rp->ru_majflt)), 0);
hv_store(h, "nswap", 5, newSVnv(NO_FREEBSD_4x(rp->ru_nswap)), 0);
hv_store(h, "inblock", 7, newSVnv(NO_FREEBSD_4x(rp->ru_inblock)), 0);
hv_store(h, "oublock", 7, newSVnv(NO_FREEBSD_4x(rp->ru_oublock)), 0);
hv_store(h, "msgsnd", 6, newSVnv(NO_FREEBSD_4x(rp->ru_msgsnd)), 0);
hv_store(h, "msgrcv", 6, newSVnv(NO_FREEBSD_4x(rp->ru_msgrcv)), 0);
hv_store(h, "nsignals", 8, newSViv(NO_FREEBSD_4x(rp->ru_nsignals)), 0);
hv_store(h, "nvcsw", 5, newSViv(NO_FREEBSD_4x(rp->ru_nvcsw)), 0);
hv_store(h, "nivcsw", 6, newSViv(NO_FREEBSD_4x(rp->ru_nivcsw)), 0);
/* attributes available only in FreeBSD 6.x */
hv_store(h, "emul", 4, newSVpv(NO_FREEBSD_5x_pv(kp->ki_emul), 0), 0);
hv_store(h, "jid", 3, newSViv(NO_FREEBSD_5x(kp->ki_jid)), 0);
hv_store(h, "numthreads", 10, newSViv(NO_FREEBSD_5x(kp->ki_numthreads)), 0);
NO_FREEBSD_5x(rp = &kp->ki_rusage_ch);
hv_store(h, "utime_ch", 8, newSVnv(NO_FREEBSD_5x(TIME_FRAC(rp->ru_utime))), 0);
hv_store(h, "stime_ch", 8, newSVnv(NO_FREEBSD_5x(TIME_FRAC(rp->ru_stime))), 0);
hv_store(h, "time_ch", 7, newSVnv(NO_FREEBSD_5x(
TIME_FRAC(rp->ru_utime)+TIME_FRAC(rp->ru_stime))), 0);
hv_store(h, "maxrss_ch", 9, newSVnv(NO_FREEBSD_5x(rp->ru_maxrss)), 0);
hv_store(h, "ixrss_ch", 8, newSVnv(NO_FREEBSD_5x(rp->ru_ixrss)), 0);
hv_store(h, "idrss_ch", 8, newSVnv(NO_FREEBSD_5x(rp->ru_idrss)), 0);
hv_store(h, "isrss_ch", 8, newSVnv(NO_FREEBSD_5x(rp->ru_isrss)), 0);
hv_store(h, "minflt_ch", 9, newSVnv(NO_FREEBSD_5x(rp->ru_minflt)), 0);
hv_store(h, "majflt_ch", 9, newSVnv(NO_FREEBSD_5x(rp->ru_majflt)), 0);
hv_store(h, "nswap_ch", 8, newSVnv(NO_FREEBSD_5x(rp->ru_nswap)), 0);
hv_store(h, "inblock_ch", 10, newSVnv(NO_FREEBSD_5x(rp->ru_inblock)), 0);
hv_store(h, "oublock_ch", 10, newSVnv(NO_FREEBSD_5x(rp->ru_oublock)), 0);
hv_store(h, "msgsnd_ch", 9, newSVnv(NO_FREEBSD_5x(rp->ru_msgsnd)), 0);
hv_store(h, "msgrcv_ch", 9, newSVnv(NO_FREEBSD_5x(rp->ru_msgrcv)), 0);
( run in 0.761 second using v1.01-cache-2.11-cpan-39bf76dae61 )