Return 0 on success and -1 on error.

This commit is contained in:
Martin Baulig
1999-10-24 20:17:42 +00:00
parent 507f171b63
commit 7a9bb6e43d
20 changed files with 153 additions and 65 deletions

View File

@@ -50,6 +50,8 @@ glibtop_init_proc_state_p (glibtop *server)
{
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state |
_glibtop_sysdeps_proc_state_new;
return 0;
}
/* Provides detailed information about a process. */
@@ -67,13 +69,13 @@ glibtop_get_proc_state_p (glibtop *server,
memset (buf, 0, sizeof (glibtop_proc_state));
/* It does not work for the swapper task. */
if (pid == 0) return;
if (pid == 0) return -1;
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
return -1;
}
strncpy (buf->cmd, pinfo [0].kp_proc.p_comm, sizeof (buf->cmd)-1);
@@ -109,7 +111,7 @@ glibtop_get_proc_state_p (glibtop *server,
buf->state = GLIBTOP_PROCESS_ZOMBIE;
break;
default:
return;
return -1;
}
#else
switch (pinfo [0].kp_proc.p_stat) {
@@ -129,9 +131,11 @@ glibtop_get_proc_state_p (glibtop *server,
buf->state = 'Z';
break;
default:
return;
return -1;
}
#endif
buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
return 0;
}