Skip to content

Commit cb1fe5a

Browse files
fix: extract detach to fix windows build
1 parent 589e32b commit cb1fe5a

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

src/internal/handle_panel_movement.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os/exec"
77
"path/filepath"
88
"runtime"
9-
"syscall"
109

1110
tea "github.com/charmbracelet/bubbletea"
1211

@@ -98,13 +97,7 @@ func (m *model) executeOpenCommand() {
9897
}
9998

10099
cmd := exec.Command(openCommand, panel.element[panel.cursor].location)
101-
if runtime.GOOS != utils.OsWindows {
102-
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
103-
// Optionally, redirect stdio to avoid terminal hangups
104-
cmd.Stdin = nil
105-
cmd.Stdout = nil
106-
cmd.Stderr = nil
107-
}
100+
utils.DetachFromTerminal(cmd)
108101
err := cmd.Start()
109102
if err != nil {
110103
slog.Error("Error while open file with", "error", err)

src/internal/utils/detach_unix.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
// Stdin/Stdout/Stderr default to os.DevNull when nil; no extra wiring needed.
14+
}
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)