Add --list-processes to list running -r/--run sessions
Lists every session pid file found under
$XDG_STATE_HOME/slocker-lite/run/, showing pid, container name, and
status (running or exited). Status is determined the same way any
external tool could check it: a non-blocking exclusive flock() on the
file that succeeds means it's actually stale (nothing holds it), so
the session is reported as exited in that case; the lock is always
released again immediately, never left held by the check itself.
list_sessions() (pid_file.{h,cpp}) reads the real pid from each file's
own contents rather than parsing it out of the filename, which would
be ambiguous for container names that themselves contain '-'.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
This commit is contained in:
@@ -62,6 +62,7 @@ slocker-lite -v|--volume <name> <directory>
|
||||
slocker-lite --list-volumes
|
||||
slocker-lite --delete-volume <name>
|
||||
slocker-lite --delete-volume-full <name>
|
||||
slocker-lite --list-processes
|
||||
slocker-lite -t|--test
|
||||
slocker-lite -h|--help
|
||||
slocker-lite -V|--version
|
||||
@@ -83,6 +84,7 @@ slocker-lite -V|--version
|
||||
| `--list-volumes` | List all named volumes (see `-v/--volume`) with their host directory. |
|
||||
| `--delete-volume <name>` | Remove a named volume from the config. The host directory is left untouched. |
|
||||
| `--delete-volume-full <name>` | Like `--delete-volume`, but also recursively deletes the volume's host directory. |
|
||||
| `--list-processes` | List running `--run` sessions found by their pid files under `$XDG_STATE_HOME/slocker-lite/run/`, with their pid, container name, and status (`running` or `exited`). |
|
||||
| `-t, --test` | Print which `bwrap --unshare-xxx` namespaces the running kernel supports. |
|
||||
| `--log-level <level>` | Set log verbosity (`trace`, `debug`, `info`, `warn`, `error`, `critical`, `off`). |
|
||||
| `-h, --help` | Print usage and exit. |
|
||||
@@ -126,6 +128,9 @@ sudo ./buildDir/slocker-lite -r myimage.tar --user git
|
||||
|
||||
# Remove a named volume and delete its host directory too
|
||||
./buildDir/slocker-lite --delete-volume-full mydata
|
||||
|
||||
# List currently running (and any leftover, exited) --run sessions
|
||||
./buildDir/slocker-lite --list-processes
|
||||
```
|
||||
|
||||
## Configuration
|
||||
@@ -170,7 +175,9 @@ PID file under `$XDG_STATE_HOME/slocker-lite/run/` (falling back to
|
||||
`$HOME/.local/state/...`), named after the image and its PID so the same image can
|
||||
be run concurrently without collisions. The file is removed automatically once the
|
||||
run ends; any tool can check whether a session is still alive by attempting the
|
||||
same exclusive, non-blocking `flock()` on its file.
|
||||
same exclusive, non-blocking `flock()` on its file. `--list-processes` does
|
||||
exactly that for every pid file it finds, reporting each one's pid, container
|
||||
name, and `running`/`exited` status.
|
||||
|
||||
See `CLAUDE.md` for the full architecture writeup (file-by-file breakdown, the
|
||||
reasoning behind each of the above, and known gaps).
|
||||
|
||||
Reference in New Issue
Block a user