**** Merged from HEAD ****
Use `(1L << feature)' instead of `(1 << feature)' to avoid problems with integer overflows when we add more fields.
This commit is contained in:
@@ -26,14 +26,14 @@
|
||||
#include <glibtop/cpu.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu =
|
||||
(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) +
|
||||
(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) +
|
||||
(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY);
|
||||
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
|
||||
(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) +
|
||||
(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu_smp =
|
||||
(1 << GLIBTOP_XCPU_TOTAL) + (1 << GLIBTOP_XCPU_USER) +
|
||||
(1 << GLIBTOP_XCPU_NICE) + (1 << GLIBTOP_XCPU_SYS) +
|
||||
(1 << GLIBTOP_XCPU_IDLE);
|
||||
(1L << GLIBTOP_XCPU_TOTAL) + (1L << GLIBTOP_XCPU_USER) +
|
||||
(1L << GLIBTOP_XCPU_NICE) + (1L << GLIBTOP_XCPU_SYS) +
|
||||
(1L << GLIBTOP_XCPU_IDLE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -26,12 +26,12 @@
|
||||
#include <glibtop/loadavg.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg =
|
||||
(1 << GLIBTOP_LOADAVG_LOADAVG);
|
||||
(1L << GLIBTOP_LOADAVG_LOADAVG);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg_tasks =
|
||||
(1 << GLIBTOP_LOADAVG_NR_RUNNING) +
|
||||
(1 << GLIBTOP_LOADAVG_NR_TASKS) +
|
||||
(1 << GLIBTOP_LOADAVG_LAST_PID);
|
||||
(1L << GLIBTOP_LOADAVG_NR_RUNNING) +
|
||||
(1L << GLIBTOP_LOADAVG_NR_TASKS) +
|
||||
(1L << GLIBTOP_LOADAVG_LAST_PID);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -26,10 +26,10 @@
|
||||
#include <glibtop/mem.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_mem =
|
||||
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
||||
(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_SHARED) +
|
||||
(1 << GLIBTOP_MEM_BUFFER) + (1 << GLIBTOP_MEM_CACHED) +
|
||||
(1 << GLIBTOP_MEM_USER);
|
||||
(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) +
|
||||
(1L << GLIBTOP_MEM_FREE) + (1L << GLIBTOP_MEM_SHARED) +
|
||||
(1L << GLIBTOP_MEM_BUFFER) + (1L << GLIBTOP_MEM_CACHED) +
|
||||
(1L << GLIBTOP_MEM_USER);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -27,10 +27,10 @@
|
||||
#include <sys/msg.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||
(1 << GLIBTOP_IPC_MSGPOOL) + (1 << GLIBTOP_IPC_MSGMAP) +
|
||||
(1 << GLIBTOP_IPC_MSGMAX) + (1 << GLIBTOP_IPC_MSGMNB) +
|
||||
(1 << GLIBTOP_IPC_MSGMNI) + (1 << GLIBTOP_IPC_MSGSSZ) +
|
||||
(1 << GLIBTOP_IPC_MSGTQL);
|
||||
(1L << GLIBTOP_IPC_MSGPOOL) + (1L << GLIBTOP_IPC_MSGMAP) +
|
||||
(1L << GLIBTOP_IPC_MSGMAX) + (1L << GLIBTOP_IPC_MSGMNB) +
|
||||
(1L << GLIBTOP_IPC_MSGMNI) + (1L << GLIBTOP_IPC_MSGSSZ) +
|
||||
(1L << GLIBTOP_IPC_MSGTQL);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -51,40 +51,40 @@
|
||||
#define _GLIBTOP_IP_FW_ACCTOUT 0x2000 /* Account outgoing packets only. */
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netload =
|
||||
(1 << GLIBTOP_NETLOAD_ERRORS_IN) +
|
||||
(1 << GLIBTOP_NETLOAD_ERRORS_OUT) +
|
||||
(1 << GLIBTOP_NETLOAD_COLLISIONS);
|
||||
(1L << GLIBTOP_NETLOAD_ERRORS_IN) +
|
||||
(1L << GLIBTOP_NETLOAD_ERRORS_OUT) +
|
||||
(1L << GLIBTOP_NETLOAD_COLLISIONS);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netload_data =
|
||||
(1 << GLIBTOP_NETLOAD_ADDRESS) +
|
||||
(1 << GLIBTOP_NETLOAD_SUBNET) +
|
||||
(1 << GLIBTOP_NETLOAD_MTU);
|
||||
(1L << GLIBTOP_NETLOAD_ADDRESS) +
|
||||
(1L << GLIBTOP_NETLOAD_SUBNET) +
|
||||
(1L << GLIBTOP_NETLOAD_MTU);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netload_bytes =
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_IN) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_OUT) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_TOTAL);
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_IN) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_OUT) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netload_packets =
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_IN) +
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_OUT) +
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_TOTAL);
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netload_total =
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_TOTAL);
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netload_in =
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_TOTAL) +
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_IN) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_IN);
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_IN);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netload_out =
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_TOTAL) +
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_OUT) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_OUT);
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_OUT);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -118,47 +118,47 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
|
||||
|
||||
strcpy (ifr.ifr_name, interface);
|
||||
if (!ioctl (skfd, SIOCGIFFLAGS, &ifr)) {
|
||||
buf->flags |= (1 << GLIBTOP_NETLOAD_IF_FLAGS);
|
||||
buf->flags |= (1L << GLIBTOP_NETLOAD_IF_FLAGS);
|
||||
flags = ifr.ifr_flags;
|
||||
} else
|
||||
flags = 0;
|
||||
|
||||
if (flags & IFF_UP)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_UP);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_UP);
|
||||
|
||||
if (flags & IFF_BROADCAST)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_BROADCAST);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_BROADCAST);
|
||||
|
||||
if (flags & IFF_DEBUG)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_DEBUG);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_DEBUG);
|
||||
|
||||
if (flags & IFF_LOOPBACK)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_LOOPBACK);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LOOPBACK);
|
||||
|
||||
if (flags & IFF_POINTOPOINT)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_POINTOPOINT);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_POINTOPOINT);
|
||||
|
||||
if (flags & IFF_RUNNING)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_RUNNING);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_RUNNING);
|
||||
|
||||
if (flags & IFF_NOARP)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_NOARP);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_NOARP);
|
||||
|
||||
if (flags & IFF_PROMISC)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_PROMISC);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_PROMISC);
|
||||
|
||||
if (flags & IFF_ALLMULTI)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_ALLMULTI);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_ALLMULTI);
|
||||
|
||||
if (flags & IFF_MULTICAST)
|
||||
buf->if_flags |= (1 << GLIBTOP_IF_FLAGS_MULTICAST);
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_MULTICAST);
|
||||
|
||||
strcpy (ifr.ifr_name, interface);
|
||||
if (!ioctl (skfd, SIOCGIFADDR, &ifr)) {
|
||||
struct sockaddr_in addr =
|
||||
*(struct sockaddr_in *) &ifr.ifr_addr;
|
||||
buf->address = addr.sin_addr.s_addr;
|
||||
buf->flags |= (1 << GLIBTOP_NETLOAD_ADDRESS);
|
||||
buf->flags |= (1L << GLIBTOP_NETLOAD_ADDRESS);
|
||||
}
|
||||
|
||||
strcpy (ifr.ifr_name, interface);
|
||||
@@ -166,13 +166,13 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
|
||||
struct sockaddr_in addr =
|
||||
*(struct sockaddr_in *) &ifr.ifr_addr;
|
||||
buf->subnet = addr.sin_addr.s_addr;
|
||||
buf->flags |= (1 << GLIBTOP_NETLOAD_SUBNET);
|
||||
buf->flags |= (1L << GLIBTOP_NETLOAD_SUBNET);
|
||||
}
|
||||
|
||||
strcpy (ifr.ifr_name, interface);
|
||||
if (!ioctl (skfd, SIOCGIFMTU, &ifr)) {
|
||||
buf->mtu = ifr.ifr_mtu;
|
||||
buf->flags |= (1 << GLIBTOP_NETLOAD_MTU);
|
||||
buf->flags |= (1L << GLIBTOP_NETLOAD_MTU);
|
||||
}
|
||||
|
||||
close (skfd);
|
||||
|
@@ -34,8 +34,8 @@
|
||||
#include <glib.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_ppp =
|
||||
(1 << GLIBTOP_PPP_STATE) + (1 << GLIBTOP_PPP_BYTES_IN) +
|
||||
(1 << GLIBTOP_PPP_BYTES_OUT);
|
||||
(1L << GLIBTOP_PPP_STATE) + (1L << GLIBTOP_PPP_BYTES_IN) +
|
||||
(1L << GLIBTOP_PPP_BYTES_OUT);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -187,13 +187,13 @@ glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device)
|
||||
if (is_ISDN_on (server, &online)) {
|
||||
buf->state = online ? GLIBTOP_PPP_STATE_ONLINE :
|
||||
GLIBTOP_PPP_STATE_HANGUP;
|
||||
buf->flags |= (1 << GLIBTOP_PPP_STATE);
|
||||
buf->flags |= (1L << GLIBTOP_PPP_STATE);
|
||||
}
|
||||
|
||||
if (get_ISDN_stats (server, &in, &out)) {
|
||||
buf->bytes_in = in;
|
||||
buf->bytes_out = out;
|
||||
buf->flags |= (1 << GLIBTOP_PPP_BYTES_IN) |
|
||||
(1 << GLIBTOP_PPP_BYTES_OUT);
|
||||
buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) |
|
||||
(1L << GLIBTOP_PPP_BYTES_OUT);
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <glibtop/procargs.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_args =
|
||||
(1 << GLIBTOP_PROC_ARGS_SIZE);
|
||||
(1L << GLIBTOP_PROC_ARGS_SIZE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -26,10 +26,10 @@
|
||||
#include <glibtop/prockernel.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_kernel =
|
||||
(1 << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1 << GLIBTOP_PROC_KERNEL_MIN_FLT) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_MAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_CMIN_FLT) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_CMAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_KSTK_ESP) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_KSTK_EIP) + (1 << GLIBTOP_PROC_KERNEL_WCHAN);
|
||||
(1L << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1L << GLIBTOP_PROC_KERNEL_MIN_FLT) +
|
||||
(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT) + (1L << GLIBTOP_PROC_KERNEL_CMIN_FLT) +
|
||||
(1L << GLIBTOP_PROC_KERNEL_CMAJ_FLT) + (1L << GLIBTOP_PROC_KERNEL_KSTK_ESP) +
|
||||
(1L << GLIBTOP_PROC_KERNEL_KSTK_EIP) + (1L << GLIBTOP_PROC_KERNEL_WCHAN);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -34,8 +34,8 @@
|
||||
#include <ctype.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proclist =
|
||||
(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) +
|
||||
(1 << GLIBTOP_PROCLIST_SIZE);
|
||||
(1L << GLIBTOP_PROCLIST_TOTAL) + (1L << GLIBTOP_PROCLIST_NUMBER) +
|
||||
(1L << GLIBTOP_PROCLIST_SIZE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -122,28 +122,28 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
||||
case GLIBTOP_KERN_PROC_PGRP:
|
||||
/* Do you really, really need this ? */
|
||||
glibtop_get_proc_uid_s (server, &procuid, pid);
|
||||
if (procuid.flags & (1 << GLIBTOP_PROC_UID_PGRP))
|
||||
if (procuid.flags & (1L << GLIBTOP_PROC_UID_PGRP))
|
||||
if ((int) arg != procuid.pgrp)
|
||||
continue;
|
||||
break;
|
||||
case GLIBTOP_KERN_PROC_SESSION:
|
||||
/* Do you really, really need this ? */
|
||||
glibtop_get_proc_uid_s (server, &procuid, pid);
|
||||
if (procuid.flags & (1 << GLIBTOP_PROC_UID_SESSION))
|
||||
if (procuid.flags & (1L << GLIBTOP_PROC_UID_SESSION))
|
||||
if ((int) arg != procuid.session)
|
||||
continue;
|
||||
break;
|
||||
case GLIBTOP_KERN_PROC_TTY:
|
||||
/* Do you really, really need this ? */
|
||||
glibtop_get_proc_uid_s (server, &procuid, pid);
|
||||
if (procuid.flags & (1 << GLIBTOP_PROC_UID_TTY))
|
||||
if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY))
|
||||
if ((int) arg != procuid.tty)
|
||||
continue;
|
||||
break;
|
||||
case GLIBTOP_KERN_PROC_RUID:
|
||||
/* Do you really, really need this ? */
|
||||
glibtop_get_proc_uid_s (server, &procuid, pid);
|
||||
if (procuid.flags & (1 << GLIBTOP_PROC_UID_EUID))
|
||||
if (procuid.flags & (1L << GLIBTOP_PROC_UID_EUID))
|
||||
if ((int) arg != procuid.euid)
|
||||
continue;
|
||||
break;
|
||||
@@ -151,19 +151,19 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
||||
|
||||
if (which & GLIBTOP_EXCLUDE_NOTTY) {
|
||||
glibtop_get_proc_uid_s (server, &procuid, pid);
|
||||
if (procuid.flags & (1 << GLIBTOP_PROC_UID_TTY))
|
||||
if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY))
|
||||
if (procuid.tty == -1) continue;
|
||||
}
|
||||
|
||||
if (which & GLIBTOP_EXCLUDE_IDLE) {
|
||||
glibtop_get_proc_state_s (server, &procstate, pid);
|
||||
if (procstate.flags & (1 << GLIBTOP_PROC_STATE_STATE))
|
||||
if (procstate.flags & (1L << GLIBTOP_PROC_STATE_STATE))
|
||||
if (procstate.state != 'R') continue;
|
||||
}
|
||||
|
||||
if (which & GLIBTOP_EXCLUDE_SYSTEM) {
|
||||
glibtop_get_proc_uid_s (server, &procuid, pid);
|
||||
if (procuid.flags & (1 << GLIBTOP_PROC_UID_UID))
|
||||
if (procuid.flags & (1L << GLIBTOP_PROC_UID_UID))
|
||||
if (procuid.uid == 0) continue;
|
||||
}
|
||||
|
||||
|
@@ -27,14 +27,14 @@
|
||||
#include <glibtop/procmap.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_map =
|
||||
(1 << GLIBTOP_PROC_MAP_NUMBER) + (1 << GLIBTOP_PROC_MAP_TOTAL) +
|
||||
(1 << GLIBTOP_PROC_MAP_SIZE);
|
||||
(1L << GLIBTOP_PROC_MAP_NUMBER) + (1L << GLIBTOP_PROC_MAP_TOTAL) +
|
||||
(1L << GLIBTOP_PROC_MAP_SIZE);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_map_entry =
|
||||
(1 << GLIBTOP_MAP_ENTRY_START) + (1 << GLIBTOP_MAP_ENTRY_END) +
|
||||
(1 << GLIBTOP_MAP_ENTRY_OFFSET) + (1 << GLIBTOP_MAP_ENTRY_PERM) +
|
||||
(1 << GLIBTOP_MAP_ENTRY_INODE) + (1 << GLIBTOP_MAP_ENTRY_DEVICE) +
|
||||
(1 << GLIBTOP_MAP_ENTRY_FILENAME);
|
||||
(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) +
|
||||
(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM) +
|
||||
(1L << GLIBTOP_MAP_ENTRY_INODE) + (1L << GLIBTOP_MAP_ENTRY_DEVICE) +
|
||||
(1L << GLIBTOP_MAP_ENTRY_FILENAME);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -26,12 +26,12 @@
|
||||
#include <glibtop/procmem.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_mem =
|
||||
(1 << GLIBTOP_PROC_MEM_VSIZE) + (1 << GLIBTOP_PROC_MEM_RSS) +
|
||||
(1 << GLIBTOP_PROC_MEM_RSS_RLIM);
|
||||
(1L << GLIBTOP_PROC_MEM_VSIZE) + (1L << GLIBTOP_PROC_MEM_RSS) +
|
||||
(1L << GLIBTOP_PROC_MEM_RSS_RLIM);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_mem_statm =
|
||||
(1 << GLIBTOP_PROC_MEM_SIZE) + (1 << GLIBTOP_PROC_MEM_RESIDENT) +
|
||||
(1 << GLIBTOP_PROC_MEM_SHARE);
|
||||
(1L << GLIBTOP_PROC_MEM_SIZE) + (1L << GLIBTOP_PROC_MEM_RESIDENT) +
|
||||
(1L << GLIBTOP_PROC_MEM_SHARE);
|
||||
|
||||
#ifndef LOG1024
|
||||
#define LOG1024 10
|
||||
|
@@ -26,16 +26,16 @@
|
||||
#include <glibtop/procsegment.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_segment =
|
||||
(1 << GLIBTOP_PROC_SEGMENT_START_CODE) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_END_CODE) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_START_STACK);
|
||||
(1L << GLIBTOP_PROC_SEGMENT_START_CODE) +
|
||||
(1L << GLIBTOP_PROC_SEGMENT_END_CODE) +
|
||||
(1L << GLIBTOP_PROC_SEGMENT_START_STACK);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_segment_statm =
|
||||
(1 << GLIBTOP_PROC_SEGMENT_TEXT_RSS) +
|
||||
(1L << GLIBTOP_PROC_SEGMENT_TEXT_RSS) +
|
||||
/* Disabled due to bug in the Linux Kernel. */
|
||||
/* (1 << GLIBTOP_PROC_SEGMENT_SHLIB_RSS) + */
|
||||
(1 << GLIBTOP_PROC_SEGMENT_DATA_RSS) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_DIRTY_SIZE);
|
||||
/* (1L << GLIBTOP_PROC_SEGMENT_SHLIB_RSS) + */
|
||||
(1L << GLIBTOP_PROC_SEGMENT_DATA_RSS) +
|
||||
(1L << GLIBTOP_PROC_SEGMENT_DIRTY_SIZE);
|
||||
|
||||
#ifndef LOG1024
|
||||
#define LOG1024 10
|
||||
|
@@ -26,8 +26,8 @@
|
||||
#include <glibtop/procsignal.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_signal =
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1 << GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1 << GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1L << GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1L << GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -28,10 +28,10 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state =
|
||||
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE);
|
||||
(1L << GLIBTOP_PROC_STATE_CMD) + (1L << GLIBTOP_PROC_STATE_STATE);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state_uid =
|
||||
(1 << GLIBTOP_PROC_STATE_UID) + (1 << GLIBTOP_PROC_STATE_GID);
|
||||
(1L << GLIBTOP_PROC_STATE_UID) + (1L << GLIBTOP_PROC_STATE_GID);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -26,14 +26,14 @@
|
||||
#include <glibtop/proctime.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_time =
|
||||
(1 << GLIBTOP_PROC_TIME_UTIME) + (1 << GLIBTOP_PROC_TIME_CUTIME) +
|
||||
(1 << GLIBTOP_PROC_TIME_STIME) + (1 << GLIBTOP_PROC_TIME_CSTIME) +
|
||||
(1 << GLIBTOP_PROC_TIME_RTIME) + (1 << GLIBTOP_PROC_TIME_FREQUENCY) +
|
||||
(1 << GLIBTOP_PROC_TIME_TIMEOUT) + (1 << GLIBTOP_PROC_TIME_IT_REAL_VALUE) +
|
||||
(1 << GLIBTOP_PROC_TIME_START_TIME);
|
||||
(1L << GLIBTOP_PROC_TIME_UTIME) + (1L << GLIBTOP_PROC_TIME_CUTIME) +
|
||||
(1L << GLIBTOP_PROC_TIME_STIME) + (1L << GLIBTOP_PROC_TIME_CSTIME) +
|
||||
(1L << GLIBTOP_PROC_TIME_RTIME) + (1L << GLIBTOP_PROC_TIME_FREQUENCY) +
|
||||
(1L << GLIBTOP_PROC_TIME_TIMEOUT) + (1L << GLIBTOP_PROC_TIME_IT_REAL_VALUE) +
|
||||
(1L << GLIBTOP_PROC_TIME_START_TIME);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_time_smp =
|
||||
(1 << GLIBTOP_PROC_TIME_XCPU_UTIME) + (1 << GLIBTOP_PROC_TIME_XCPU_STIME);
|
||||
(1L << GLIBTOP_PROC_TIME_XCPU_UTIME) + (1L << GLIBTOP_PROC_TIME_XCPU_STIME);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -26,14 +26,14 @@
|
||||
#include <glibtop/procuid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_uid =
|
||||
(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) +
|
||||
(1 << GLIBTOP_PROC_UID_GID) + (1 << GLIBTOP_PROC_UID_EGID);
|
||||
(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) +
|
||||
(1L << GLIBTOP_PROC_UID_GID) + (1L << GLIBTOP_PROC_UID_EGID);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_uid_stat =
|
||||
(1 << GLIBTOP_PROC_UID_PID) + (1 << GLIBTOP_PROC_UID_PPID) +
|
||||
(1 << GLIBTOP_PROC_UID_PGRP) + (1 << GLIBTOP_PROC_UID_SESSION) +
|
||||
(1 << GLIBTOP_PROC_UID_TTY) + (1 << GLIBTOP_PROC_UID_TPGID) +
|
||||
(1 << GLIBTOP_PROC_UID_PRIORITY) + (1 << GLIBTOP_PROC_UID_NICE);
|
||||
(1L << GLIBTOP_PROC_UID_PID) + (1L << GLIBTOP_PROC_UID_PPID) +
|
||||
(1L << GLIBTOP_PROC_UID_PGRP) + (1L << GLIBTOP_PROC_UID_SESSION) +
|
||||
(1L << GLIBTOP_PROC_UID_TTY) + (1L << GLIBTOP_PROC_UID_TPGID) +
|
||||
(1L << GLIBTOP_PROC_UID_PRIORITY) + (1L << GLIBTOP_PROC_UID_NICE);
|
||||
|
||||
#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
|
||||
|
||||
|
@@ -42,11 +42,11 @@ union semun
|
||||
#endif
|
||||
|
||||
static unsigned long _glibtop_sysdeps_sem_limits =
|
||||
(1 << GLIBTOP_IPC_SEMMAP) + (1 << GLIBTOP_IPC_SEMMNI) +
|
||||
(1 << GLIBTOP_IPC_SEMMNS) + (1 << GLIBTOP_IPC_SEMMNU) +
|
||||
(1 << GLIBTOP_IPC_SEMMSL) + (1 << GLIBTOP_IPC_SEMOPM) +
|
||||
(1 << GLIBTOP_IPC_SEMUME) + (1 << GLIBTOP_IPC_SEMUSZ) +
|
||||
(1 << GLIBTOP_IPC_SEMVMX) + (1 << GLIBTOP_IPC_SEMAEM);
|
||||
(1L << GLIBTOP_IPC_SEMMAP) + (1L << GLIBTOP_IPC_SEMMNI) +
|
||||
(1L << GLIBTOP_IPC_SEMMNS) + (1L << GLIBTOP_IPC_SEMMNU) +
|
||||
(1L << GLIBTOP_IPC_SEMMSL) + (1L << GLIBTOP_IPC_SEMOPM) +
|
||||
(1L << GLIBTOP_IPC_SEMUME) + (1L << GLIBTOP_IPC_SEMUSZ) +
|
||||
(1L << GLIBTOP_IPC_SEMVMX) + (1L << GLIBTOP_IPC_SEMAEM);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -27,9 +27,9 @@
|
||||
#include <sys/shm.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_shm_limits =
|
||||
(1 << GLIBTOP_IPC_SHMMAX) + (1 << GLIBTOP_IPC_SHMMIN) +
|
||||
(1 << GLIBTOP_IPC_SHMMNI) + (1 << GLIBTOP_IPC_SHMSEG) +
|
||||
(1 << GLIBTOP_IPC_SHMALL);
|
||||
(1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN) +
|
||||
(1L << GLIBTOP_IPC_SHMMNI) + (1L << GLIBTOP_IPC_SHMSEG) +
|
||||
(1L << GLIBTOP_IPC_SHMALL);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -28,11 +28,11 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_swap =
|
||||
(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) +
|
||||
(1 << GLIBTOP_SWAP_FREE);
|
||||
(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) +
|
||||
(1L << GLIBTOP_SWAP_FREE);
|
||||
|
||||
static unsigned long _glibtop_sysdeps_swap_paging =
|
||||
(1 << GLIBTOP_SWAP_PAGEIN) + (1 << GLIBTOP_SWAP_PAGEOUT);
|
||||
(1L << GLIBTOP_SWAP_PAGEIN) + (1L << GLIBTOP_SWAP_PAGEOUT);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include <glibtop/sysinfo.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_sysinfo =
|
||||
(1 << GLIBTOP_SYSINFO_CPUINFO);
|
||||
(1L << GLIBTOP_SYSINFO_CPUINFO);
|
||||
|
||||
static glibtop_sysinfo sysinfo;
|
||||
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include <glibtop/uptime.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_uptime =
|
||||
(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME);
|
||||
(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_IDLETIME);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -1,3 +1,8 @@
|
||||
1999-05-11 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* procstate.c: Fixed implementation of the `state' field; added
|
||||
`ruid' and `rgid' fields.
|
||||
|
||||
1999-02-19 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* procmap.c, procargs.c, netload.c: Copied from stub_suid.
|
||||
|
@@ -26,9 +26,9 @@
|
||||
#include <glibtop/cpu.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu =
|
||||
(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) +
|
||||
(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) +
|
||||
(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY);
|
||||
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
|
||||
(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) +
|
||||
(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include <glibtop/loadavg.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg =
|
||||
(1 << GLIBTOP_LOADAVG_LOADAVG);
|
||||
(1L << GLIBTOP_LOADAVG_LOADAVG);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -32,8 +32,8 @@
|
||||
#include <mach/vm_statistics.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_mem =
|
||||
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
||||
(1 << GLIBTOP_MEM_FREE);
|
||||
(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) +
|
||||
(1L << GLIBTOP_MEM_FREE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -26,9 +26,9 @@
|
||||
#include <glibtop/msg_limits.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||
(1 << GLIBTOP_IPC_MSGMAP) + (1 << GLIBTOP_IPC_MSGMAX) +
|
||||
(1 << GLIBTOP_IPC_MSGMNB) + (1 << GLIBTOP_IPC_MSGMNI) +
|
||||
(1 << GLIBTOP_IPC_MSGTQL);
|
||||
(1L << GLIBTOP_IPC_MSGMAP) + (1L << GLIBTOP_IPC_MSGMAX) +
|
||||
(1L << GLIBTOP_IPC_MSGMNB) + (1L << GLIBTOP_IPC_MSGMNI) +
|
||||
(1L << GLIBTOP_IPC_MSGTQL);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -54,7 +54,7 @@ glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_MSGMAX);
|
||||
buf->flags += (1L << GLIBTOP_IPC_MSGMAX);
|
||||
|
||||
buf->msgmax = value;
|
||||
|
||||
@@ -63,7 +63,7 @@ glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_MSGMNB);
|
||||
buf->flags += (1L << GLIBTOP_IPC_MSGMNB);
|
||||
|
||||
buf->msgmnb = value;
|
||||
|
||||
@@ -72,7 +72,7 @@ glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_MSGMNI);
|
||||
buf->flags += (1L << GLIBTOP_IPC_MSGMNI);
|
||||
|
||||
buf->msgmni = value;
|
||||
|
||||
@@ -81,7 +81,7 @@ glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_MSGTQL);
|
||||
buf->flags += (1L << GLIBTOP_IPC_MSGTQL);
|
||||
|
||||
buf->msgtql = value;
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
#define BIT_SHIFT(x) (1 << (x % 32))
|
||||
#define BIT_SHIFT(x) (1L << (x % 64))
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_procdata_0 =
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_CMD) +
|
||||
|
@@ -29,8 +29,8 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proclist =
|
||||
(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) +
|
||||
(1 << GLIBTOP_PROCLIST_SIZE);
|
||||
(1L << GLIBTOP_PROCLIST_TOTAL) + (1L << GLIBTOP_PROCLIST_NUMBER) +
|
||||
(1L << GLIBTOP_PROCLIST_SIZE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -36,8 +36,8 @@
|
||||
#include <mach/task_info.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_mem =
|
||||
(1 << GLIBTOP_PROC_MEM_VSIZE) + (1 << GLIBTOP_PROC_MEM_RESIDENT) +
|
||||
(1 << GLIBTOP_PROC_MEM_RSS);
|
||||
(1L << GLIBTOP_PROC_MEM_VSIZE) + (1L << GLIBTOP_PROC_MEM_RESIDENT) +
|
||||
(1L << GLIBTOP_PROC_MEM_RSS);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -98,6 +98,6 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
||||
|
||||
buf->share = u.u_ru.ru_ixrss;
|
||||
|
||||
buf->flags |= (1 << GLIBTOP_PROC_MEM_RSS_RLIM) |
|
||||
(1 << GLIBTOP_PROC_MEM_SHARE);
|
||||
buf->flags |= (1L << GLIBTOP_PROC_MEM_RSS_RLIM) |
|
||||
(1L << GLIBTOP_PROC_MEM_SHARE);
|
||||
}
|
||||
|
@@ -29,11 +29,11 @@
|
||||
#include <sys/user.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_segment =
|
||||
(1 << GLIBTOP_PROC_SEGMENT_TEXT_RSS) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_DATA_RSS) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_START_CODE) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_END_CODE) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_START_STACK);
|
||||
(1L << GLIBTOP_PROC_SEGMENT_TEXT_RSS) +
|
||||
(1L << GLIBTOP_PROC_SEGMENT_DATA_RSS) +
|
||||
(1L << GLIBTOP_PROC_SEGMENT_START_CODE) +
|
||||
(1L << GLIBTOP_PROC_SEGMENT_END_CODE) +
|
||||
(1L << GLIBTOP_PROC_SEGMENT_START_STACK);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -28,8 +28,8 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_signal =
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1 << GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1 << GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1L << GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1L << GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -27,9 +27,14 @@
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <mach.h>
|
||||
#include <mach/mach_types.h>
|
||||
#include <mach/task_info.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state =
|
||||
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE) +
|
||||
(1 << GLIBTOP_PROC_STATE_UID);
|
||||
(1L << GLIBTOP_PROC_STATE_CMD) +
|
||||
(1L << GLIBTOP_PROC_STATE_UID) + (1L << GLIBTOP_PROC_STATE_GID) +
|
||||
(1L << GLIBTOP_PROC_STATE_RUID) + (1L << GLIBTOP_PROC_STATE_RGID);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -46,7 +51,8 @@ glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct tbl_procinfo procinfo;
|
||||
int ret;
|
||||
int minim_state = 99, ret;
|
||||
task_t thistask;
|
||||
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
|
||||
|
||||
@@ -65,14 +71,85 @@ glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
/* Check whether the process actually exists. */
|
||||
if (procinfo.pi_status == PI_EMPTY) return;
|
||||
|
||||
/* Check whether it is not a zombie. */
|
||||
if (procinfo.pi_status == PI_ZOMBIE) {
|
||||
buf->state = GLIBTOP_PROCESS_ZOMBIE;
|
||||
buf->flags = (1L << GLIBTOP_PROC_STATE_STATE);
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy (buf->cmd, procinfo.pi_comm, sizeof (buf->cmd)-1);
|
||||
|
||||
buf->cmd [sizeof (buf->cmd)-1] = 0;
|
||||
|
||||
buf->state = procinfo.pi_status;
|
||||
|
||||
buf->uid = procinfo.pi_uid;
|
||||
buf->uid = procinfo.pi_svuid;
|
||||
buf->gid = procinfo.pi_svgid;
|
||||
buf->ruid = procinfo.pi_ruid;
|
||||
buf->rgid = procinfo.pi_rgid;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_state;
|
||||
|
||||
/* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
|
||||
|
||||
glibtop_suid_enter (server);
|
||||
|
||||
/* Get task structure. */
|
||||
ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask);
|
||||
|
||||
if (ret == KERN_SUCCESS) {
|
||||
thread_array_t threadarr;
|
||||
unsigned int threadarr_l;
|
||||
thread_basic_info_t threadinfo;
|
||||
thread_basic_info_data_t threadinfodata;
|
||||
int j;
|
||||
|
||||
/* Get thread array. */
|
||||
(void) task_threads (thistask, &threadarr, &threadarr_l);
|
||||
|
||||
threadinfo = &threadinfodata;
|
||||
for (j = 0; j < threadarr_l; j++) {
|
||||
unsigned int threadinfo_l = THREAD_BASIC_INFO_COUNT;
|
||||
int tret;
|
||||
|
||||
tret = thread_info (threadarr [j], THREAD_BASIC_INFO,
|
||||
(thread_info_t) threadinfo, &threadinfo_l);
|
||||
|
||||
if (tret == KERN_SUCCESS) {
|
||||
if (minim_state > threadinfo->run_state)
|
||||
minim_state=threadinfo->run_state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glibtop_suid_leave (server);
|
||||
|
||||
/* !!! END OF SUID ROOT PART !!! */
|
||||
|
||||
if (ret != KERN_SUCCESS) return;
|
||||
|
||||
switch (minim_state) {
|
||||
case TH_STATE_RUNNING:
|
||||
buf->state = GLIBTOP_PROCESS_RUNNING;
|
||||
break;
|
||||
case TH_STATE_UNINTERRUPTIBLE:
|
||||
buf->state = GLIBTOP_PROCESS_UNINTERRUPTIBLE;
|
||||
break;
|
||||
case TH_STATE_WAITING:
|
||||
buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
|
||||
break;
|
||||
case TH_STATE_STOPPED:
|
||||
case TH_STATE_HALTED:
|
||||
buf->state = GLIBTOP_PROCESS_STOPPED;
|
||||
break;
|
||||
default:
|
||||
if (ret != KERN_SUCCESS)
|
||||
buf->state = GLIBTOP_PROCESS_ZOMBIE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (buf->state)
|
||||
buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
|
||||
}
|
||||
|
@@ -30,9 +30,9 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_time =
|
||||
(1 << GLIBTOP_PROC_TIME_UTIME) + (1 << GLIBTOP_PROC_TIME_CUTIME) +
|
||||
(1 << GLIBTOP_PROC_TIME_STIME) + (1 << GLIBTOP_PROC_TIME_CSTIME) +
|
||||
(1 << GLIBTOP_PROC_TIME_START_TIME);
|
||||
(1L << GLIBTOP_PROC_TIME_UTIME) + (1L << GLIBTOP_PROC_TIME_CUTIME) +
|
||||
(1L << GLIBTOP_PROC_TIME_STIME) + (1L << GLIBTOP_PROC_TIME_CSTIME) +
|
||||
(1L << GLIBTOP_PROC_TIME_START_TIME);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -36,11 +36,11 @@
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_uid =
|
||||
(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) +
|
||||
(1 << GLIBTOP_PROC_UID_GID) + (1 << GLIBTOP_PROC_UID_EGID) +
|
||||
(1 << GLIBTOP_PROC_UID_PID) + (1 << GLIBTOP_PROC_UID_PPID) +
|
||||
(1 << GLIBTOP_PROC_UID_PGRP) + (1 << GLIBTOP_PROC_UID_SESSION) +
|
||||
(1 << GLIBTOP_PROC_UID_TTY) + (1 << GLIBTOP_PROC_UID_TPGID);
|
||||
(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) +
|
||||
(1L << GLIBTOP_PROC_UID_GID) + (1L << GLIBTOP_PROC_UID_EGID) +
|
||||
(1L << GLIBTOP_PROC_UID_PID) + (1L << GLIBTOP_PROC_UID_PPID) +
|
||||
(1L << GLIBTOP_PROC_UID_PGRP) + (1L << GLIBTOP_PROC_UID_SESSION) +
|
||||
(1L << GLIBTOP_PROC_UID_TTY) + (1L << GLIBTOP_PROC_UID_TPGID);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -118,7 +118,7 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
|
||||
|
||||
buf->priority = taskinfo.base_priority;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_PROC_UID_PRIORITY);
|
||||
buf->flags += (1L << GLIBTOP_PROC_UID_PRIORITY);
|
||||
|
||||
errno = 0;
|
||||
|
||||
@@ -128,5 +128,5 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
|
||||
|
||||
buf->nice = ret;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_PROC_UID_NICE);
|
||||
buf->flags += (1L << GLIBTOP_PROC_UID_NICE);
|
||||
}
|
||||
|
@@ -26,9 +26,9 @@
|
||||
#include <glibtop/sem_limits.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_sem_limits =
|
||||
(1 << GLIBTOP_IPC_SEMMNI) + (1 << GLIBTOP_IPC_SEMMSL) +
|
||||
(1 << GLIBTOP_IPC_SEMOPM) + (1 << GLIBTOP_IPC_SEMVMX) +
|
||||
(1 << GLIBTOP_IPC_SEMAEM);
|
||||
(1L << GLIBTOP_IPC_SEMMNI) + (1L << GLIBTOP_IPC_SEMMSL) +
|
||||
(1L << GLIBTOP_IPC_SEMOPM) + (1L << GLIBTOP_IPC_SEMVMX) +
|
||||
(1L << GLIBTOP_IPC_SEMAEM);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -54,7 +54,7 @@ glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SEMMNI);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SEMMNI);
|
||||
|
||||
buf->semmni = value;
|
||||
|
||||
@@ -64,7 +64,7 @@ glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SEMMSL);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SEMMSL);
|
||||
|
||||
buf->semmsl = value;
|
||||
|
||||
@@ -74,7 +74,7 @@ glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SEMOPM);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SEMOPM);
|
||||
|
||||
buf->semopm = value;
|
||||
|
||||
@@ -84,7 +84,7 @@ glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SEMUME);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SEMUME);
|
||||
|
||||
buf->semume = value;
|
||||
|
||||
@@ -94,7 +94,7 @@ glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SEMVMX);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SEMVMX);
|
||||
|
||||
buf->semvmx = value;
|
||||
|
||||
@@ -104,7 +104,7 @@ glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SEMAEM);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SEMAEM);
|
||||
|
||||
buf->semaem = value;
|
||||
}
|
||||
|
@@ -26,8 +26,8 @@
|
||||
#include <glibtop/shm_limits.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_shm_limits =
|
||||
(1 << GLIBTOP_IPC_SHMMAX) + (1 << GLIBTOP_IPC_SHMMIN) +
|
||||
(1 << GLIBTOP_IPC_SHMMNI) + (1 << GLIBTOP_IPC_SHMSEG);
|
||||
(1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN) +
|
||||
(1L << GLIBTOP_IPC_SHMMNI) + (1L << GLIBTOP_IPC_SHMSEG);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -53,7 +53,7 @@ glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SHMMAX);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SHMMAX);
|
||||
|
||||
buf->shmmax = value;
|
||||
|
||||
@@ -63,7 +63,7 @@ glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SHMMIN);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SHMMIN);
|
||||
|
||||
buf->shmmin = value;
|
||||
|
||||
@@ -73,7 +73,7 @@ glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SHMMNI);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SHMMNI);
|
||||
|
||||
buf->shmmni = value;
|
||||
|
||||
@@ -83,7 +83,7 @@ glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
|
||||
|
||||
if (ret != 1) return;
|
||||
|
||||
buf->flags += (1 << GLIBTOP_IPC_SHMSEG);
|
||||
buf->flags += (1L << GLIBTOP_IPC_SHMSEG);
|
||||
|
||||
buf->shmseg = value;
|
||||
}
|
||||
|
@@ -26,8 +26,8 @@
|
||||
#include <glibtop/swap.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_swap =
|
||||
(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) +
|
||||
(1 << GLIBTOP_SWAP_FREE);
|
||||
(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) +
|
||||
(1L << GLIBTOP_SWAP_FREE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include <time.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_uptime =
|
||||
(1 << GLIBTOP_UPTIME_UPTIME);
|
||||
(1L << GLIBTOP_UPTIME_UPTIME);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
|
Reference in New Issue
Block a user