TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / external / process-cpp-minimal / include / core / posix / linux / proc / process / stat.h
1 /*
2  * Copyright © 2012-2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef CORE_POSIX_LINUX_PROC_PROCESS_STAT_H_
19 #define CORE_POSIX_LINUX_PROC_PROCESS_STAT_H_
20
21 #include <core/posix/linux/proc/process/state.h>
22
23 #include <core/posix/visibility.h>
24
25 #include <string>
26
27 namespace core
28 {
29 namespace posix
30 {
31 class Process;
32 namespace linux
33 {
34 namespace proc
35 {
36 namespace process
37 {
38 /**
39  * @brief The Stat struct encapsulates status information about a process.
40  */
41 struct CORE_POSIX_DLL_PUBLIC Stat
42 {
43     pid_t pid = 1; ///< The process ID
44     std::string executable; ///< The filename of the executable, in parentheses.
45     State state = State::undefined; ///< State of the process.
46     pid_t parent = -1; ///< The PID of the parent.
47     pid_t process_group = -1; ///< The process group ID of the process.
48     int session_id = -1; ///< The session ID of the process.
49     int tty_nr = -1; ///< The controlling terminal of the process.
50     int controlling_process_group = -1; ///< The ID of the foreground process group of the controlling terminal of the process.
51     unsigned int kernel_flags = 0; ///< The kernel flags word of the process.
52     long unsigned int minor_faults_count = 0; ///< The number of minor faults the process has made which have not required loading a memory page from disk.
53     long unsigned int minor_faults_count_by_children = 0; ///< The number of minor faults that the process's waited-for children have made.
54     long unsigned int major_faults_count = 0; ///< The number of major faults the process has made which have required loading a memory page from disk.
55     long unsigned int major_faults_count_by_children = 0; ///< The number of major faults that the process's waited-for children have made.
56     struct
57     {
58         long unsigned int user = 0; ///<  Amount of time that this process has been scheduled in user mode, [clock ticks].
59         long unsigned int system = 0; ///< Amount of time that this process has been scheduled in kernel mode, [clock ticks].
60         long unsigned int user_for_children = 0; ///< Amount of time that this process's waited-for children have been scheduled in user mode, [clock ticks].
61         long unsigned int system_for_children = 0; ///< Amount of time that this process's waited-for children have been scheduled in kernel mode, [clock ticks].
62     } time;
63     /**
64      * (Explanation for Linux 2.6) For processes running a real-time scheduling
65      * policy (policy below; see sched_setscheduler(2)), this is the negated
66      * scheduling priority, minus one; that is, a number in the range -2 to
67      * -100, corresponding to real-time priorities 1 to 99. For processes running
68      * under a non-real-time scheduling policy, this is the raw nice value
69      * (setpriority(2)) as represented in the kernel. The kernel stores nice
70      * values as numbers in the range 0 (high) to 39 (low), corresponding to
71      * the user-visible nice range of -20 to 19.
72      *
73      *Before Linux 2.6, this was a scaled value based on the scheduler
74      *weighting given to this process.
75      */
76     long int priority = 0;
77     long int nice = 0; ///< The nice value (see setpriority(2)), a value in the range 19 (low priority) to -20 (high priority).
78     long int thread_count = 0; ///< Number of threads in this process (since Linux 2.6).
79     long int time_before_next_sig_alarm = 0; ///< The time in jiffies before the next SIGALRM is sent to the process due to an interval timer. Since kernel 2.6.17, this field is no longer maintained, and  is hard coded as 0.
80     long int start_time = 0; ///< The time the process started after system boot.  In kernels before Linux 2.6, this value was expressed in jiffies.  Since Linux 2.6, the value is expressed in clock ticks (divide by sysconf(_SC_CLK_TCK)).
81     struct
82     {
83         long unsigned int virt = 0; ///< Virtual memory size in bytes.
84         long unsigned int resident_set = 0; ///< Resident Set Size: number of pages the process has in real memory.  This is just the pages which count toward text, data, or stack space. This does not include pages which have not been demand-loaded in, or which are swapped out.
85         long unsigned int resident_set_limit = 0; ///< Current soft limit in bytes on the rss of the process; see the description of RLIMIT_RSS in getrlimit(2).
86     } size;
87     struct
88     {
89         long unsigned int start_code = 0; ///< The address above which program text can run.
90         long unsigned int end_code = 0; ///< The address below which program text can run.
91         long unsigned int start_stack = 0; ///< The address of the start (i.e., bottom) of the stack.
92         long unsigned int stack_pointer = 0; ///< The current value of ESP (stack pointer), as found in the kernel stack page for the process.
93         long unsigned int instruction_pointer = 0; ///< The current EIP (instruction pointer).
94     } addresses;
95     struct
96     {
97         long unsigned int pending = 0; ///< The bitmap of pending signals, displayed as a decimal number.  Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead.
98         long unsigned int blocked = 0; ///< The bitmap of blocked signals, displayed as a decimal number.  Obsolete, because it does not provide information on real-time signals; use  /proc/[pid]/status instead.
99         long unsigned int ignored = 0; ///< The bitmap of ignored signals, displayed as a decimal number.  Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead.
100         long unsigned int caught = 0; ///< The bitmap of caught signals, displayed as a decimal number.  Obsolete, because it does not provide information on real-time signals;  use  /proc/[pid]/status instead.
101     } signals;
102     long unsigned int channel = 0; ///< This is the "channel" in which the process is waiting.  It is the address of a system call, and can be looked up in a namelist if you need a textual name. (If you have an up-to-date /etc/psdatabase, then try ps -l to see the WCHAN field in action.)
103     long unsigned int swap_count = 0; ///< Number of pages swapped (not maintained).
104     long unsigned int swap_count_children = 0; ///< Cumulative nswap for child processes (not maintained).
105     int exit_signal = -1; ///< Signal to be sent to parent when we die.
106     int cpu_count = -1; ///< CPU number last executed on.
107     unsigned int realtime_priority = 0; ///< Real-time scheduling priority, a number in the range 1 to 99 for processes scheduled under  a  real-time  policy,  or  0,  for  non-real-time  processes  (see sched_setscheduler(2)).
108     unsigned int scheduling_policy = 0; ///< Scheduling policy (see sched_setscheduler(2)). Decode using the SCHED_* constants in linux/sched.h.
109     long long unsigned int aggregated_block_io_delays = 0; ///< Aggregated block I/O delays, measured in clock ticks (centiseconds).
110     long unsigned int guest_time = 0; ///< Guest time of the process (time spent running a virtual CPU for a guest operating system), measured in clock ticks.
111     long unsigned int guest_time_children = 0; ///< Guest time of the process's children, measured in clock ticks.
112 };
113
114 CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, Stat& stat);
115 }
116 }
117 }
118 }
119 }
120 #endif // CORE_POSIX_LINUX_PROC_PROCESS_STAT_H_