diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b9dc19a6..1b7957f6 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -13,13 +13,14 @@ builds: goos: - darwin - linux + - windows goarch: - amd64 - arm64 hooks: post: - mkdir -p dist/bin/{{ .Os }}/{{ .Arch }} - - cp {{ .Path }} dist/bin/{{ .Os }}/{{ .Arch }}/orun + - cp {{ .Path }} dist/bin/{{ .Os }}/{{ .Arch }}/orun{{ .Ext }} archives: - id: orun-archive @@ -27,6 +28,10 @@ archives: - orun formats: - tar.gz + format_overrides: + - goos: windows + formats: + - zip name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" checksum: diff --git a/cmd/orun/command_run_background.go b/cmd/orun/command_run_background.go index 4874969f..9b6f5a3e 100644 --- a/cmd/orun/command_run_background.go +++ b/cmd/orun/command_run_background.go @@ -6,7 +6,6 @@ import ( "os/exec" "path/filepath" "strings" - "syscall" "github.com/sourceplane/orun/internal/ui" ) @@ -54,7 +53,7 @@ func startBackgroundRun(execID string, color bool) error { "ORUN_EXEC_ID="+execID, "ORUN_NO_COLOR=1", ) - cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} + cmd.SysProcAttr = backgroundSysProcAttr() if err := cmd.Start(); err != nil { logFile.Close() diff --git a/cmd/orun/command_run_background_unix.go b/cmd/orun/command_run_background_unix.go new file mode 100644 index 00000000..8bfa34a2 --- /dev/null +++ b/cmd/orun/command_run_background_unix.go @@ -0,0 +1,11 @@ +//go:build unix + +package main + +import "syscall" + +// backgroundSysProcAttr puts the detached run in its own process group so a +// signal to the launching terminal does not reach it. +func backgroundSysProcAttr() *syscall.SysProcAttr { + return &syscall.SysProcAttr{Setpgid: true} +} diff --git a/cmd/orun/command_run_background_windows.go b/cmd/orun/command_run_background_windows.go new file mode 100644 index 00000000..f0ec0244 --- /dev/null +++ b/cmd/orun/command_run_background_windows.go @@ -0,0 +1,11 @@ +//go:build windows + +package main + +import "syscall" + +// backgroundSysProcAttr starts the detached run in a new process group so a +// Ctrl+C in the launching console does not reach it. +func backgroundSysProcAttr() *syscall.SysProcAttr { + return &syscall.SysProcAttr{CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP} +}