Skip to content

xcheckrestart: reports docker/podman processes #302

@usagi-flow

Description

@usagi-flow

It would seem like xcheckrestart reports processes which run in a container, but are not/never were installed on the host system:

$ xbps-query -s postgre (reports nothing)

$ xcheckrestart:

22684 /usr/local/bin/postgres ()
22691 /usr/local/bin/postgres ()
22998 /usr/local/bin/postgres ()
22999 /usr/local/bin/postgres ()
23007 /usr/local/bin/postgres ()
23008 /usr/local/bin/postgres ()
23016 /usr/local/bin/postgres ()
23017 /usr/local/bin/postgres ()
23018 /usr/local/bin/postgres ()
23027 /usr/local/bin/postgres ()
23028 /usr/local/bin/postgres ()
23048 /usr/local/bin/postgres ()
23049 /usr/local/bin/postgres ()
23050 /usr/local/bin/postgres ()
23441 /usr/local/bin/postgres ()
23442 /usr/local/bin/postgres ()
2667 /usr/local/bin/postgres ()
28263 /usr/local/bin/postgres ()
32512 /usr/local/bin/postgres ()
4953 /usr/local/bin/postgres ()
4955 /usr/local/bin/postgres ()
5031 /usr/local/bin/postgres ()
5032 /usr/local/bin/postgres ()
5033 /usr/local/bin/postgres ()
5949 /usr/local/bin/postgres ()
751 /usr/local/bin/postgres ()
752 /usr/local/bin/postgres ()

Idea

Maybe we could inspect /proc/<pid>/cgroup for each process before printing them out, and avoid printing them if the cgroup paths are not "/", as in this example:
$ cat /proc/752/cgroup:

12:name=systemd:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
11:pids:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
10:net_prio:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
9:perf_event:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
8:net_cls:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
7:freezer:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
6:devices:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
5:memory:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
4:blkio:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
3:cpuacct:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
2:cpu:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
1:cpuset:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
0::/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67d

On the host, I would expect non-containerized processes to output something like this:
$ cat /proc/1/cgroup:

12:name=systemd:/
11:pids:/
10:net_prio:/
9:perf_event:/
8:net_cls:/
7:freezer:/
6:devices:/
5:memory:/
4:blkio:/
3:cpuacct:/
2:cpu:/
1:cpuset:/
0::/

The downside might be a performance hit...

PS: Thank you for this wonderful collection of tools!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions