Distinguish between GLIBTOP_ERROR_NO_KERNEL_SUPPORT and

1999-12-22  Martin Baulig  <martin@home-of-linux.org>

	* procdata.c: Distinguish between GLIBTOP_ERROR_NO_KERNEL_SUPPORT
	and GLIBTOP_ERROR_NO_SUCH_PROCESS.
This commit is contained in:
Martin Baulig
1999-12-22 12:59:36 +00:00
committed by Martin Baulig
parent 1ad3a69d8f
commit ac0cce9d6f
2 changed files with 35 additions and 5 deletions

View File

@@ -1,5 +1,8 @@
1999-12-22 Martin Baulig <martin@home-of-linux.org> 1999-12-22 Martin Baulig <martin@home-of-linux.org>
* procdata.c: Distinguish between GLIBTOP_ERROR_NO_KERNEL_SUPPORT
and GLIBTOP_ERROR_NO_SUCH_PROCESS.
* procdata.c (glibtop_get_proc_data_proc_state_s): Return * procdata.c (glibtop_get_proc_data_proc_state_s): Return
-GLIBTOP_ERROR_NO_SUCH_PROCESS if the process doesn't exist. -GLIBTOP_ERROR_NO_SUCH_PROCESS if the process doesn't exist.
(glibtop_get_proc_data_proc_mem_s): Likewise. (glibtop_get_proc_data_proc_mem_s): Likewise.

View File

@@ -31,6 +31,9 @@ glibtop_get_proc_data_stat_s (glibtop *server, libgtop_stat_t *stat)
size_t size = sizeof (libgtop_stat_t); size_t size = sizeof (libgtop_stat_t);
if (sysctl (name, 2, stat, &size, NULL, 0)) { if (sysctl (name, 2, stat, &size, NULL, 0)) {
if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else
glibtop_warn_io_r (server, "sysctl (libgtop/stat)"); glibtop_warn_io_r (server, "sysctl (libgtop/stat)");
return -1; return -1;
} }
@@ -45,6 +48,9 @@ glibtop_get_proc_data_mem_s (glibtop *server, libgtop_mem_t *mem)
size_t size = sizeof (libgtop_mem_t); size_t size = sizeof (libgtop_mem_t);
if (sysctl (name, 2, mem, &size, NULL, 0)) { if (sysctl (name, 2, mem, &size, NULL, 0)) {
if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else
glibtop_warn_io_r (server, "sysctl (libgtop/mem)"); glibtop_warn_io_r (server, "sysctl (libgtop/mem)");
return -1; return -1;
} }
@@ -59,6 +65,9 @@ glibtop_get_proc_data_swap_s (glibtop *server, libgtop_swap_t *swap)
size_t size = sizeof (libgtop_swap_t); size_t size = sizeof (libgtop_swap_t);
if (sysctl (name, 2, swap, &size, NULL, 0)) { if (sysctl (name, 2, swap, &size, NULL, 0)) {
if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else
glibtop_warn_io_r (server, "sysctl (libgtop/swap)"); glibtop_warn_io_r (server, "sysctl (libgtop/swap)");
return -1; return -1;
} }
@@ -75,6 +84,9 @@ glibtop_get_proc_data_proclist_s (glibtop *server,
size_t size = sizeof (libgtop_proclist_t); size_t size = sizeof (libgtop_proclist_t);
if (sysctl (name, 4, proclist, &size, NULL, 0)) { if (sysctl (name, 4, proclist, &size, NULL, 0)) {
if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else
glibtop_warn_io_r (server, "sysctl (libgtop/proclist)"); glibtop_warn_io_r (server, "sysctl (libgtop/proclist)");
return -1; return -1;
} }
@@ -93,6 +105,8 @@ glibtop_get_proc_data_proc_state_s (glibtop *server,
if (sysctl (name, 3, proc_state, &size, NULL, 0)) { if (sysctl (name, 3, proc_state, &size, NULL, 0)) {
if (errno == ENOTDIR) if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else if (errno == ESRCH)
return -GLIBTOP_ERROR_NO_SUCH_PROCESS; return -GLIBTOP_ERROR_NO_SUCH_PROCESS;
else else
glibtop_warn_io_r (server, "sysctl (libgtop/proc_state)"); glibtop_warn_io_r (server, "sysctl (libgtop/proc_state)");
@@ -112,6 +126,8 @@ glibtop_get_proc_data_proc_mem_s (glibtop *server,
if (sysctl (name, 3, proc_mem, &size, NULL, 0)) { if (sysctl (name, 3, proc_mem, &size, NULL, 0)) {
if (errno == ENOTDIR) if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else if (errno == ESRCH)
return -GLIBTOP_ERROR_NO_SUCH_PROCESS; return -GLIBTOP_ERROR_NO_SUCH_PROCESS;
else else
glibtop_warn_io_r (server, "sysctl (libgtop/proc_mem)"); glibtop_warn_io_r (server, "sysctl (libgtop/proc_mem)");
@@ -131,6 +147,8 @@ glibtop_get_proc_data_proc_signal_s (glibtop *server,
if (sysctl (name, 3, proc_signal, &size, NULL, 0)) { if (sysctl (name, 3, proc_signal, &size, NULL, 0)) {
if (errno == ENOTDIR) if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else if (errno == ESRCH)
return -GLIBTOP_ERROR_NO_SUCH_PROCESS; return -GLIBTOP_ERROR_NO_SUCH_PROCESS;
else else
glibtop_warn_io_r (server, "sysctl (libgtop/proc_signal)"); glibtop_warn_io_r (server, "sysctl (libgtop/proc_signal)");
@@ -150,6 +168,8 @@ glibtop_get_proc_data_proc_kernel_s (glibtop *server,
if (sysctl (name, 3, proc_kernel, &size, NULL, 0)) { if (sysctl (name, 3, proc_kernel, &size, NULL, 0)) {
if (errno == ENOTDIR) if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else if (errno == ESRCH)
return -GLIBTOP_ERROR_NO_SUCH_PROCESS; return -GLIBTOP_ERROR_NO_SUCH_PROCESS;
else else
glibtop_warn_io_r (server, "sysctl (libgtop/proc_kernel)"); glibtop_warn_io_r (server, "sysctl (libgtop/proc_kernel)");
@@ -168,6 +188,8 @@ glibtop_get_proc_data_proc_args_s (glibtop *server, pid_t pid,
if (sysctl (name, 3, result, &size, NULL, 0)) { if (sysctl (name, 3, result, &size, NULL, 0)) {
if (errno == ENOTDIR) if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else if (errno == ESRCH)
return -GLIBTOP_ERROR_NO_SUCH_PROCESS; return -GLIBTOP_ERROR_NO_SUCH_PROCESS;
else else
glibtop_warn_io_r (server, "sysctl (libgtop/proc_args)"); glibtop_warn_io_r (server, "sysctl (libgtop/proc_args)");
@@ -187,6 +209,8 @@ glibtop_get_proc_data_proc_maps_s (glibtop *server, pid_t pid,
if (sysctl (name, 3, result, &size, NULL, 0)) { if (sysctl (name, 3, result, &size, NULL, 0)) {
if (errno == ENOTDIR) if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else if (errno == ESRCH)
return -GLIBTOP_ERROR_NO_SUCH_PROCESS; return -GLIBTOP_ERROR_NO_SUCH_PROCESS;
else else
glibtop_warn_io_r (server, "sysctl (libgtop/proc_maps)"); glibtop_warn_io_r (server, "sysctl (libgtop/proc_maps)");
@@ -205,6 +229,9 @@ glibtop_get_proc_data_netload_s (glibtop *server,
size_t size = sizeof (libgtop_netload_t); size_t size = sizeof (libgtop_netload_t);
if (sysctl (name, 2, netload, &size, (char *) device, strlen (device)+1)) { if (sysctl (name, 2, netload, &size, (char *) device, strlen (device)+1)) {
if (errno == ENOTDIR)
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
else
glibtop_warn_io_r (server, "sysctl (libgtop/netload)"); glibtop_warn_io_r (server, "sysctl (libgtop/netload)");
return -1; return -1;
} }