Skip to content

feat(process,cclip): explicit kill Result + lockfile semantics; clean fullscreen; stable Kitty/Foot clearing; config error UX; v2.3.0-seedclay#17

Merged
Mjoyufull merged 5 commits intoMjoyufull:devfrom
Marbowls:main
Nov 12, 2025

Conversation

@Marbowls
Copy link
Contributor

Change kill_process_sigterm from a void wrapper to return Result<(), std::io::Error>, checking libc::kill()'s return value and mapping failures with std::io::Error::last_os_error().

This exposes errno (ESRCH/EPERM/etc.) to callers, avoids silent failures and unsafe/manual errno access, and provides

Change kill_process_sigterm from a void wrapper to return
Result<(), std::io::Error>, checking libc::kill()'s return value and
mapping failures with std::io::Error::last_os_error().

This exposes errno (ESRCH/EPERM/etc.) to callers, avoids silent failures
and unsafe/manual errno access, and provides
@Mjoyufull Mjoyufull self-requested a review October 29, 2025 23:10
@Mjoyufull Mjoyufull changed the base branch from main to dev October 29, 2025 23:14
@Mjoyufull
Copy link
Owner

thanks for the pr twin, i appreciate the effort and the intent to make kill() handling more explicit.
but we have a few issues to address before we can merge this PR

  1. Update the API and all call sites (pick one of these)
  • Option A (preferred, non-breaking): add a new fallible helper:
    • pub fn kill_process_sigterm_result(pid: i32) -> Result<(), std::io::Error>
    • keep the existing pub fn kill_process_sigterm(pid: i32) wrapper that calls the new helper and ignores/logs the Result.
    • Update only the sensitive call site(s) (see - 4) to use the new _result helper and handle errors.
  • Option B (breaking, if you want to enforce handling everywhere): change kill_process_sigterm to return Result and update every internal caller in the repo to handle Result. If you choose this, note that it’s an incompatible source change — we’ll treat it as internal until dev → main, but be explicit in the PR description about the breaking nature.
  1. Fix the cclip lock path semantics (must do)
  • In run_cclip_mode (src/main.rs) the code currently calls kill_process_sigterm(pid) and then removes the lockfile unconditionally. That can allow a second instance to start if kill() fails (EPERM) while the old process remained alive.
  • Update that flow so we only remove the lock when:
    • kill succeeded (OK), or
    • the error is ESRCH (no such process).
  • For EPERM or other errors, return an error or surface a clear message so we don’t silently remove the lockfile.
  1. Be consistent with other kill usages
  • The repo contains inline libc::kill uses (e.g. src/modes/app_launcher/run.rs) that implement a “send SIGTERM, poll via kill(..., 0), then SIGKILL” pattern.
  • Either leave those inline behaviors alone (recommended) or refactor them to use the new helper consistently. If you refactor, keep the existing escalation logic intact.
  1. Tests / build / lint
  • Run cargo build and cargo test locally and report results in the PR.
  • Run cargo fmt and cargo clippy; fix any warnings/errors you introduce.
  • If possible, add a test or mention manual steps that exercise the cclip lock path (simulate ESRCH/EPERM behavior) so reviewers can reproduce reasoning.
  1. PR description and metadata
  • Update the PR description to follow CONTRIBUTING.md: summary of changes, tests performed, and whether this is breaking or not.

  • If you changed behavior (e.g., how the lockfile is removed), note that in the description.

  • If you want, tag me or @me in the comment when you’ve pushed the updates and I’ll re-review quickly. I also retarget the base to dev for you as per the CONTRIBUTING.md guided.

thanks again — the change makes sense and i'm happy to merge once the PR compiles cleanly in-tree, and either preserves backwards compatibility via a wrapper or updates all call sites and documents it.

- Added kill_process_sigterm_result that returns Result<(), io::Error>
- kill_process_sigterm now just wraps it and logs errors instead of propagating
- Updated main.rs and app_launcher/run.rs to handle process kill errors explicitly
- Makes process termination more reliable, especially when replacing old instances
…andling

- Change `kill_process_sigterm_result` to return raw errno
- Remove lockfile only after confirming process termination or staleness (ESRCH)
- Propagate non-ESRCH errors when killing processes in cclip and app launcher modes
@Marbowls Marbowls changed the title process: make kill_process_sigterm return Result and surface OS errors Refactor process killing: kill_process_sigterm now returns Result with errno. Fixes cclip lockfile race condition by handling ESRCH (no process) and preserving lock on EPERM. Improves app_launcher error handling. Nov 8, 2025
@Marbowls
Copy link
Contributor Author

Marbowls commented Nov 8, 2025

@Mjoyufull review code

…onfig error UX; add kill helper; v2.3.0-seedclay

- Process/locking
  - Add kill_process_sigterm_result(pid) -> io::Result<()>, keep wrapper (Option A)
  - Remove cclip lock only on Ok or ESRCH; preserve on EPERM/others

- Rendering/graphics
  - Clean fullscreen (Alt+I): fully cleared background, cursor to (0,0)
    - Kitty: centered display
    - Foot/Sixel: true fullscreen
  - Tag mode: clear image on entry; suspend inline preview during tag modes; resume on exit
  - Foot/Sixel stability: pre-draw terminal.clear() on image state changes, then Clear all panels in-draw to re-sync ratatui buffer (fixes missing glyphs)

- Pipeline hygiene
  - Compute layout/wrapping inside terminal.draw()
  - Remove post-draw clearing; use in-draw Clear

- Config UX
  - Enhanced duplicate key/table error with actionable guidance (root vs [dmenu] vs [cclip])

- Misc
  - Collapse consecutive str::replace per clippy
  - Bump version to 2.3.0-seedclay (MINOR, backward compatible)
Copy link

@emendoza2014 emendoza2014 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

easy clean work finally done

Copy link
Owner

@Mjoyufull Mjoyufull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean as @emendoza2014 said. merged

@Mjoyufull Mjoyufull changed the title Refactor process killing: kill_process_sigterm now returns Result with errno. Fixes cclip lockfile race condition by handling ESRCH (no process) and preserving lock on EPERM. Improves app_launcher error handling. feat(process,cclip): explicit kill Result + lockfile semantics; clean fullscreen; stable Kitty/Foot clearing; config error UX; v2.3.0-seedclay Nov 12, 2025
@Mjoyufull Mjoyufull merged commit 106d9df into Mjoyufull:dev Nov 12, 2025
Mjoyufull added a commit that referenced this pull request Nov 12, 2025
… fullscreen; stable Kitty/Foot clearing; config error UX; v2.3.0-seedclay (#17)

* process: make kill_process_sigterm return Result and surface OS errors

Change kill_process_sigterm from a void wrapper to return Result<(), std::io::Error>, checking libc::kill()'s return value and mapping failures with std::io::Error::last_os_error().

This exposes errno (ESRCH/EPERM/etc.) to callers, avoids silent failures and unsafe/manual errno access, and provides

* feat: make process kill return Result for better error handling

- Added kill_process_sigterm_result that returns Result<(), io::Error>
- kill_process_sigterm now just wraps it and logs errors instead of propagating
- Updated main.rs and app_launcher/run.rs to handle process kill errors explicitly
- Makes process termination more reliable, especially when replacing old instances

* Fix cclip lockfile race condition and improve process killing error handling

- Change `kill_process_sigterm_result` to return raw errno
- Remove lockfile only after confirming process termination or staleness (ESRCH)
- Propagate non-ESRCH errors when killing processes in cclip and app launcher modes

* fixed small issues

* feat(process,cclip,ui): clean fullscreen; stable Kitty/Foot clears; config error UX; add kill helper; v2.3.0-seedclay

- Process/locking
  - Add kill_process_sigterm_result(pid) -> io::Result<()>, keep wrapper (Option A)
  - Remove cclip lock only on Ok or ESRCH; preserve on EPERM/others

- Rendering/graphics
  - Clean fullscreen (Alt+I): fully cleared background, cursor to (0,0)
    - Kitty: centered display
    - Foot/Sixel: true fullscreen
  - Tag mode: clear image on entry; suspend inline preview during tag modes; resume on exit
  - Foot/Sixel stability: pre-draw terminal.clear() on image state changes, then Clear all panels in-draw to re-sync ratatui buffer (fixes missing glyphs)

- Pipeline hygiene
  - Compute layout/wrapping inside terminal.draw()
  - Remove post-draw clearing; use in-draw Clear

- Config UX
  - Enhanced duplicate key/table error with actionable guidance (root vs [dmenu] vs [cclip])

- Misc
  - Collapse consecutive str::replace per clippy
  - Bump version to 2.3.0-seedclay (MINOR, backward compatible)
  @Marbowls

---------
Mjoyufull added a commit that referenced this pull request Nov 12, 2025
…s; clean fullscreen; stable Kitty/Foot clearing; config error UX; v2.3.0-seedclay (#17)"

This reverts commit 7a8a490.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants