Make --kill long-option-only, no -k short form
Per the user's request: --kill is destructive enough (stops every process a session started) that typo-prone brevity isn't worth it -- dropping the short option makes it harder to invoke by mistake. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
This commit is contained in:
@@ -38,7 +38,7 @@ Source layout (all under `src/`):
|
||||
`Mode::exec` dispatch arm) `-x/--exec <pid>`'s own pid parsing/validation
|
||||
(`ParsedArgs::exec_pid`, a positive integer or a hard error) and its
|
||||
trailing-command requirement (`ParsedArgs::command`, required non-empty).
|
||||
`-k/--kill <pid>` (`ParsedArgs::kill_pid`) shares that same positive-integer
|
||||
`--kill <pid>` (`ParsedArgs::kill_pid`) shares that same positive-integer
|
||||
parsing/validation via a small extracted `parse_pid_arg()` helper (`.cpp`-local)
|
||||
rather than duplicating the `strtol` dance a second time — unlike `-x/--exec`,
|
||||
it takes no trailing command, so it's simply not added to the leftover-args
|
||||
@@ -264,7 +264,7 @@ Source layout (all under `src/`):
|
||||
same instant everything else that needs it does, rather than needing its own
|
||||
separate pid-discovery mechanism. That same `on_start` lambda also calls
|
||||
`create_session_cgroup()` (`session_cgroup.h`, see below), right alongside
|
||||
`create_session_lock()`, so `-k/--kill` can later find every process the
|
||||
`create_session_lock()`, so `--kill` can later find every process the
|
||||
session ever starts via its dedicated cgroup; `remove_session_cgroup()` is
|
||||
called from the same post-`run_process_foreground()` spot
|
||||
`release_session_lock()` already is.
|
||||
@@ -383,7 +383,7 @@ Source layout (all under `src/`):
|
||||
a check and a later removal. Only files it actually removes are reported back
|
||||
(as `SessionInfo`s with `running=false`); still-locked (running) files are
|
||||
left untouched and not reported.
|
||||
- `session_cgroup.{h,cpp}` — gives `-k/--kill` (`kill_session.{h,cpp}`, see
|
||||
- `session_cgroup.{h,cpp}` — gives `--kill` (`kill_session.{h,cpp}`, see
|
||||
below) a reliable way to find every process a session ever started, however
|
||||
deeply forked/daemonized/reparented, by putting it in a dedicated cgroup v2
|
||||
group from the moment it starts. `cgroup_v2_available()` checks for
|
||||
@@ -429,7 +429,7 @@ Source layout (all under `src/`):
|
||||
shared by `exec_session.{h,cpp}` and `kill_session.{h,cpp}` (see both
|
||||
below); pulled into their own file (rather than staying private to
|
||||
`exec_session.cpp`, where `resolve_namespace_pid()` originally lived) once
|
||||
`-k/--kill` needed the exact same "find the real sandboxed child" logic, to
|
||||
`--kill` needed the exact same "find the real sandboxed child" logic, to
|
||||
avoid a second, drifting copy. `resolve_namespace_pid()` is unchanged from
|
||||
its original `exec_session.cpp` form (see that entry for the full
|
||||
reasoning: bwrap's own outer/tracked pid never actually enters the
|
||||
@@ -517,7 +517,7 @@ Source layout (all under `src/`):
|
||||
itself never actually enters those namespaces — comparing
|
||||
`/proc/<outer_pid>/ns/{pid,uts,ipc,cgroup}` against this process's own showed
|
||||
them identical, while only `mnt`/`user` differed. `resolve_namespace_pid()`
|
||||
(`sandbox_process.{h,cpp}` — moved out of this file once `-k/--kill`
|
||||
(`sandbox_process.{h,cpp}` — moved out of this file once `--kill`
|
||||
needed the exact same logic, see that entry) finds that real inner process
|
||||
so this can join *its* namespaces instead. For each of `{mnt→--mount, uts→--uts, ipc→--ipc, pid→--pid,
|
||||
cgroup→--cgroup, user→--user}` (`net` deliberately excluded — this project
|
||||
@@ -584,7 +584,7 @@ Source layout (all under `src/`):
|
||||
real `250:250` via the fetched `/etc/passwd` and then fails clearly (helper not
|
||||
bind-mounted, since the session itself had no declared user) rather than
|
||||
silently running as the wrong identity.
|
||||
- `kill_session.{h,cpp}` — implements `-k/--kill <pid>`, stopping a tracked,
|
||||
- `kill_session.{h,cpp}` — implements `--kill <pid>`, stopping a tracked,
|
||||
running `-r/--run` session and everything it started. `kill_session()`
|
||||
validates `pid` the same way `exec_in_session()` does (via `list_sessions()`,
|
||||
`pid_file.h`). **Real bug reported by the user against their own actual
|
||||
@@ -642,7 +642,7 @@ Source layout (all under `src/`):
|
||||
pid namespaces, unlike the user's real target device): a daemonized
|
||||
busybox session running `sh -c 'sleep 300 & exec sleep 300'` (mirroring
|
||||
the daemonize-then-exec shape of the original bug) was fully cleaned up
|
||||
by `-k/--kill`, including the backgrounded child, with no leftover
|
||||
by `--kill`, including the backgrounded child, with no leftover
|
||||
processes, mounts, or layers; a second run using `sh -c 'trap "" TERM;
|
||||
sleep 300'` (ignoring `SIGTERM` entirely) confirmed the forced-`SIGKILL`
|
||||
escalation path too, taking the full 10s grace period before the pid
|
||||
@@ -778,7 +778,7 @@ Build directory is `buildDir/` (already configured).
|
||||
(see `priv_drop_helper.cpp` in "Project state")
|
||||
- Run the executable: `./buildDir/slocker-lite -m <image.tar>` (see `--help` for the
|
||||
full flag list: `-m/--mount`, `-r/--run`, `-u/--umount`, `-c/--cleanup`,
|
||||
`-l/--list-images`, `-i/--inspect`, `-x/--exec`, `-k/--kill`, `-n/--no-nsenter`, `-D/--daemonize`,
|
||||
`-l/--list-images`, `-i/--inspect`, `-x/--exec`, `--kill`, `-n/--no-nsenter`, `-D/--daemonize`,
|
||||
`--user`, `--group`, `--hostname`, `--env`, `--env-file`, `-v/--volume`, `--list-volumes`, `--delete-volume`,
|
||||
`--delete-volume-full`, `--list-processes`, `--clean-processes`, `-t/--test`, `--log-level`,
|
||||
`-h/--help`, `-V/--version`)
|
||||
|
||||
Reference in New Issue
Block a user