Skip to content

terminal-helper: remove scripts after execution - #292

Open
myakupozluk wants to merge 1 commit into
CachyOS:developfrom
myakupozluk:fix/retain-terminal-script
Open

myakupozluk wants to merge 1 commit into
CachyOS:developfrom
myakupozluk:fix/retain-terminal-script

Conversation

@myakupozluk

Copy link
Copy Markdown

Summary

  • retain generated terminal scripts until the shell running them finishes
  • perform cleanup from the generated script itself
  • retain immediate cleanup when a non-KGX terminal fails to launch

This fixes the race where GNOME Console can let the helper exit and delete the script before pkexec starts it.

Closes #287

Validation

  • bash -n src/scripts/terminal-helper
  • exercised successful execution with a mock alacritty and verified the command completed and the temporary script was removed afterwards
  • git diff --check

Copilot AI lite review requested due to automatic review settings September 9, 2026 14:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new self-cleanup line is appended after the existing kgx SIGQUIT logic, which can prevent the cleanup rm from running and leave temporary scripts behind.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adjusts terminal-helper’s temporary-script lifecycle so GNOME Console (kgx) can’t race with the helper deleting the script before pkexec/bash starts it, by shifting cleanup into the generated script itself.

Changes:

  • Write the generated script content using printf (instead of echo) for more predictable newline handling.
  • Append a self-cleanup rm line into the generated temporary script.
  • Remove the helper’s unconditional post-launch rm to avoid deleting the script too early (while keeping immediate cleanup on non-kgx launch failure).
File summaries
File Description
src/scripts/terminal-helper Moves temp-script cleanup into the generated script to avoid kgx/pkexec race conditions.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +102 to 103
printf 'rm -f -- %q\n' "$file" >>"$file"
eval "${terminals[${terminal}]}" 2>/dev/null || {
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.

cachyos-hello Gaming package installer fails because temporary script is deleted before execution

2 participants