Esempio n. 1
0
int
sh_count_procs(char *procname)
{
    struct proc    *p;
    struct user    *u;
    int             total;

    if (kd == NULL) {
        return -1;
    }
    if (kvm_setproc(kd) < 0) {
        return (-1);
    }
    kvm_setproc(kd);
    total = 0;
    while ((p = kvm_nextproc(kd)) != NULL) {
        if (!p) {
            return (-1);
        }
        u = kvm_getu(kd, p);
        /*
         * Skip this entry if u or u->u_comm is a NULL pointer 
         */
        if (!u) {
            continue;
        }
      DEBUGMSGTL(("proc","misc1 Comparing wanted %s against %s\n",
                  procname, u->u_comm));
        if (strcmp(procname, u->u_comm) == 0)
            total++;
    }
    return (total);
}
Esempio n. 2
0
int
sh_count_regexp_procs(char *procname, pcre *regexp)
{
    struct proc    *p;
    struct user    *u;
    int             total;

    if (kd == NULL) {
        return -1;
    }
    if (kvm_setproc(kd) < 0) {
        return (-1);
    }
    kvm_setproc(kd);
    total = 0;
    while ((p = kvm_nextproc(kd)) != NULL) {
        if (!p) {
            return (-1);
        }
        u = kvm_getu(kd, p);
        /*
         * Skip this entry if u or u->u_comm is a NULL pointer 
         */
        if (!u) {
            continue;
        }
        if (strcmp(procname, u->u_comm) == 0)
            total++;
    }
    return (total);
}
Esempio n. 3
0
struct user *
tst_getu(struct proc *proc)
{
	register int e;
	struct proc tp;
	struct user *u;
	struct pid pidbuf;

	if (kvm_read(cookie, (uintptr_t)proc->p_pidp, &pidbuf,
	    sizeof (pidbuf)) != sizeof (pidbuf))
		printf("ERROR: couldn't get pid\n");

	printf("kvm_getu(pid:%d)\n", pidbuf.pid_id);
	if ((u = kvm_getu(cookie, proc)) == NULL)
		printf("ERROR: kvm_getu returned NULL\n");
	return (u);
}