Project
Loading...
Searching...
No Matches
process_iterator.h
Go to the documentation of this file.
1
22#ifndef __PROCESS_ITERATOR_H
23
24#define __PROCESS_ITERATOR_H
25
26#include <unistd.h>
27#include <limits.h>
28#include <dirent.h>
29
30//USER_HZ detection, from openssl code
31#ifndef HZ
32# if defined(_SC_CLK_TCK) \
33 && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
34# define HZ ((double)sysconf(_SC_CLK_TCK))
35# else
36# ifndef CLK_TCK
37# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
38# define HZ 100.0
39# else /* _BSD_CLK_TCK_ */
40# define HZ ((double)_BSD_CLK_TCK_)
41# endif
42# else /* CLK_TCK */
43# define HZ ((double)CLK_TCK)
44# endif
45# endif
46#endif
47
48#ifdef __FreeBSD__
49#include <kvm.h>
50#endif
51
52// process descriptor
53struct process {
54 //pid of the process
55 pid_t pid;
56 //ppid of the process
57 pid_t ppid;
58 //start time (unix timestamp)
60 //cputime used by the process (in milliseconds)
62 //actual cpu usage estimation (value in range 0-1)
63 double cpu_usage;
64 //absolute path of the executable file
65 char command[PATH_MAX+1];
66};
67
69 int pid;
71 char program_name[PATH_MAX+1];
72};
73
75#ifdef __linux__
76 DIR *dip;
77 int boot_time;
78#elif defined __FreeBSD__
79 kvm_t *kd;
80 struct kinfo_proc *procs;
81 int count;
82 int i;
83#elif defined __APPLE__
84 int i;
85 int count;
86 int *pidlist;
87#endif
89};
90
92
94
96
97#endif
int32_t i
GLint GLsizei count
Definition glcorearb.h:399
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition glcorearb.h:1308
int close_process_iterator(struct process_iterator *i)
int init_process_iterator(struct process_iterator *i, struct process_filter *filter)
int get_next_process(struct process_iterator *i, struct process *p)
char program_name[PATH_MAX+1]
struct process_filter * filter
double cpu_usage
char command[PATH_MAX+1]