Skip to content

Commit d953ece

Browse files
fix: fix child process spawning attached (#1084)
Fixes #1083 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved process launching on Linux and other non-Windows platforms: external commands now start in their own session and detach from the terminal. This prevents the app from hanging, suppresses unintended console output, and keeps the app responsive after opening files, links, or external tools. Windows and macOS behavior remains unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent bd79f4d commit d953ece

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/internal/handle_panel_movement.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func (m *model) executeOpenCommand() {
9797
}
9898

9999
cmd := exec.Command(openCommand, panel.element[panel.cursor].location)
100+
utils.DetachFromTerminal(cmd)
100101
err := cmd.Start()
101102
if err != nil {
102103
slog.Error("Error while open file with", "error", err)

src/internal/utils/detach_unix.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//go:build !windows
2+
3+
package utils
4+
5+
import (
6+
"os/exec"
7+
"syscall"
8+
)
9+
10+
func DetachFromTerminal(cmd *exec.Cmd) {
11+
// Start new session so child isn't tied to the TTY (prevents SIGHUP on terminal close).
12+
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
13+
// Optionally, redirect stdio to avoid terminal hangups
14+
cmd.Stdin = nil
15+
cmd.Stdout = nil
16+
cmd.Stderr = nil
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build windows
2+
3+
package utils
4+
5+
import "os/exec"
6+
7+
func DetachFromTerminal(cmd *exec.Cmd) {
8+
// No-op: current Windows path uses rundll32 and returns immediately.
9+
// If needed later, set CreationFlags/HideWindow via syscall.SysProcAttr.
10+
}

0 commit comments

Comments
 (0)