Repository navigation
Read the process table with ps in the box - #110
Merged
Merged
Conversation
The background probe and the tunnel reconciler read the process table with docker top, which ran ps on the host and reported host pids. The box-level stop needed the container's own pids for its kill, so it read the table a second time with ps in the box. A process list through the Docker API also had no counterpart on another runtime. All three now use one ps -eo pid,ppid,etimes,args in the box. The box image always has procps, so the age of a process is always known, and the API reports it as a number. The pids are now the box's own, so the init is pid 1 and the hold is the sleep infinity directly under it. Before, both were found by their command anywhere in the tree, so a tini or a sleep infinity that the agent started was not counted as work. Part of splitbrain#109
This was referenced Oct 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #109 (step 1).
Changes
docker topis removed. The background probe, the tunnel reconciler and the box-level stop now read the processtable with one
ps -eo pid,ppid,etimes,argsin the box (containerProcessesindocker.ts). Before, the probe andthe reconciler got host pids from
docker top, and the stop read the table a second time withpsin the box,because a
killin the box needs the box's own pids.containerProcessesFromInsideis removed.psformat withoutetimesis removed. It was there for hostpsversions that do not know it.The box image has procps, so
elapsedSecondsis always a number, inContainerProcessand in the API typeBoxWork. The dashboard no longer shows a dash for a missing age.sleep infinitywith parent pid 1. Before, it found both bytheir command anywhere in the tree, because host pids do not start at 1. So a
tinior asleep infinitythat theagent started was not counted as work. Now it is.
doc/threads.mdsays that the table comes frompsin the box.Tests
docker toptests are removed. Thepsparser test has the age column. The upstreamtest has one fake process table instead of two. A new test checks that a look-alike
tiniandsleep infinityunder the agent are work.
npm run checkand the unit tests pass. The e2e tests did not run.psformat and the parser agree with the output of a real box (procps-ng 4.0.4, tini,sleep infinity).Not tested against a real Docker daemon.
Notes for the next steps
sleep infinity, the adapters, their direct children, theresidentProcessesof a harness and thepsof thereading. A connected
boxes-filesis none of these. Without a change, the idle reaper never stops a box with aconnected file service, and the box-level stop kills the file service. Step 4 must add a rule for it in
gateway/background.ts, for example a fixed command pattern asREADING_ITSELFis forps. When the disk usage walkstarts a child process, for example
du, the rule must also cover the children of the file service. This was thesame with
docker top.boxes-setup, the agent set install and the home seed run in the boxbefore it is ready. While they run, the probe reads the box as busy. The entrypoint itself counts as work until it
replaces itself with
sleep infinity. This lasts some seconds and has no effect on the idle reaper, which acts onlyafter
IDLE_STOP_MINUTES.Runtimeinterface. The process list is now a plain command in the box throughexecInContainer.It needs no runtime method of its own and becomes
run(boxId, ['ps', '-eo', 'pid,ppid,etimes,args']). The call hasno timeout today. The timeout of
runwill apply to it.psfrom procps withetimesin the box image. A conformancetest can check that this command works in a new box.
shareProcessNamespaceis off, which is the default. With it on, pid 1 is thepauseprocess, and each box reads asbusy at all times. The box pod must not set it. A process started by an exec has parent pid 0 on both runtimes. The
adapter rules do not depend on this.