diff --git a/README.md b/README.md index 594b5c9..455ad4c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ for Linux, written on the kernel's own system-call interface. openkal = "0.23.0" [target.'cfg(os = "linux")'.dependencies] -openkal-linux = "0.24.1" +openkal-linux = "0.24.2" ``` ## Why it does not use a C library @@ -227,7 +227,9 @@ and later) instead of polling. A unit is a process group, and its use is the sum over the entries of /proc whose group is the unit's --- every program in it, including those its members -started; one read per program on the machine, made only when a caller asks. +started. Every visible program's group is queried; resident memory is read for +matching programs. If the group query is refused, the same /proc record supplies +both membership and memory. Nothing is retained between observations. `KAL_PROCESS_PROP_JOB_USAGE` is claimed. **A limit on a unit is supervised.** `kal_process_job_limit` starts, with the diff --git a/mcpp.toml b/mcpp.toml index e97726b..e0cdeff 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,7 +1,7 @@ [package] namespace = "mcpplibs" name = "openkal-linux" -version = "0.24.1" +version = "0.24.2" description = "The reference implementation of openkal for Linux, written on the kernel's own system-call interface so that it can be placed beneath a C library as well as above one." license = "Apache-2.0" diff --git a/src/process.cpp b/src/process.cpp index c0cc485..ebe9761 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -1767,6 +1767,12 @@ kal_u32 members_of(okl_long unit, okl_u64& memory) { if (name[0] < '1' || name[0] > '9') continue; okl_long pid = 0; for (const char* c = name; *c; ++c) pid = pid * 10 + (*c - '0'); + // Most visible programs belong to other units. Ask for the group + // before opening a record whose memory will then be discarded. + // A denied or unavailable query keeps the record-reading path; + // even a positive query is checked again in that same RSS record. + const okl_long group = okl::sys(okl::nr_getpgid, pid); + if (!okl::failed(group) && group != unit) continue; char b[1024]; const okl_long len = read_stat(pid, b); if (len <= 0) continue; diff --git a/src/sys.h b/src/sys.h index d226462..dca81ae 100644 --- a/src/sys.h +++ b/src/sys.h @@ -115,7 +115,7 @@ enum : okl_long { // openkal 0.13: whether a node may be started nr_fchmodat = 268, // openkal 0.11: the directory a started program runs in, and the unit it joins - nr_fchdir = 81, nr_setpgid = 109, nr_rt_sigaction = 13, + nr_fchdir = 81, nr_setpgid = 109, nr_getpgid = 121, nr_rt_sigaction = 13, // openkal.net and openkal.datagram nr_socket = 41, nr_connect = 42, nr_accept = 43, nr_sendto = 44, nr_recvfrom = 45, nr_shutdown = 48, nr_bind = 49, nr_listen = 50, @@ -223,7 +223,7 @@ enum : okl_long { // openkal 0.13: whether a node may be started nr_fchmodat = 53, // openkal 0.11: the directory a started program runs in, and the unit it joins - nr_fchdir = 50, nr_setpgid = 154, nr_rt_sigaction = 134, + nr_fchdir = 50, nr_setpgid = 154, nr_getpgid = 155, nr_rt_sigaction = 134, // openkal.net and openkal.datagram nr_socket = 198, nr_connect = 203, nr_accept = 202, nr_sendto = 206, nr_recvfrom = 207, nr_shutdown = 210, nr_bind = 200, nr_listen = 201,