Track running -r/--run sessions with a locked PID file
Each bwrap session is now recorded under $XDG_STATE_HOME/slocker-lite/run/<container-name>-<pid> (falling back to $HOME/.local/state/...), holding an exclusive advisory flock() for as long as it's running -- so any tool can tell a stale leftover file apart from a live session by attempting the same non-blocking flock(). The file is removed once the run ends, on every exit path including a forwarded Ctrl-C. run_process_foreground() gained an optional on_start(pid) callback, fired right after fork() succeeds -- the only point the real bwrap pid is knowable, since exec() (including nsenter handing off to bwrap) never changes it. run_bwrap() uses this to create/release the session lock. The container name comes from read_image_ref(), promoted from a list_oci_images()-only helper to public API in oci_image.h so run_container() can reuse the same name/tag derivation for a single image tar. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
This commit is contained in:
+2
-1
@@ -18,7 +18,8 @@ configure_file(output : 'config.h', configuration : conf_data)
|
||||
|
||||
slocker_lite = executable('slocker-lite',
|
||||
['src/main.cpp', 'src/process.cpp', 'src/oci_image.cpp', 'src/containers_storage.cpp',
|
||||
'src/bwrap.cpp', 'src/user_spec.cpp', 'src/config_file.cpp', 'src/volume_mount.cpp'],
|
||||
'src/bwrap.cpp', 'src/user_spec.cpp', 'src/config_file.cpp', 'src/volume_mount.cpp',
|
||||
'src/pid_file.cpp'],
|
||||
include_directories : include_directories('.'),
|
||||
dependencies : [fmt_dep, catch2_dep, yaml_dep, archive_dep, json_dep, spdlog_dep],
|
||||
install : true)
|
||||
|
||||
Reference in New Issue
Block a user