Skip to content

Commit 5e4b5f9

Browse files
committed
Fix Windows build: split syscall code into platform-specific files
1 parent 27c94d1 commit 5e4b5f9

File tree

5 files changed

+59
-11
lines changed

5 files changed

+59
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to Kartoza Screencaster will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.7.2] - 2026-01-25
8+
## [0.7.3] - 2026-01-25
99

1010
### Fixed
1111

@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- CI now installs CGO dependencies for Linux systray builds
2121
- Debian package includes runtime deps: `libgtk-3-0`, `libayatana-appindicator3-1`
2222
- RPM package includes runtime deps: `gtk3`, `libayatana-appindicator-gtk3`
23+
- Fixed Windows build: split syscall code into platform-specific files
2324

2425
### Platform Notes
2526
| Platform | Systray Support | Notes |
@@ -198,7 +199,7 @@ Key syndication features:
198199
- Beautiful TUI interface
199200
- CLI mode for scripting
200201

201-
[0.7.2]: https://github.com/kartoza/kartoza-screencaster/compare/v0.7.1...v0.7.2
202+
[0.7.3]: https://github.com/kartoza/kartoza-screencaster/compare/v0.7.1...v0.7.3
202203
[0.7.1]: https://github.com/kartoza/kartoza-screencaster/compare/v0.7.0...v0.7.1
203204
[0.7.0]: https://github.com/kartoza/kartoza-screencaster/compare/v0.6.1...v0.7.0
204205
[0.6.1]: https://github.com/kartoza/kartoza-screencaster/compare/v0.6.0...v0.6.1

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
flake-utils.lib.eachDefaultSystem (system:
1111
let
1212
pkgs = nixpkgs.legacyPackages.${system};
13-
version = "0.7.2";
13+
version = "0.7.3";
1414

1515
# MkDocs with Material theme for documentation
1616
mkdocsEnv = pkgs.python3.withPackages (ps: with ps; [

internal/terminal/process_unix.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//go:build !windows
2+
3+
package terminal
4+
5+
import (
6+
"os/exec"
7+
"syscall"
8+
)
9+
10+
// setSysProcAttr sets Unix-specific process attributes
11+
func setSysProcAttr(cmd *exec.Cmd) {
12+
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
13+
}
14+
15+
// stopProcess sends signals to gracefully stop the process on Unix
16+
func stopProcess(cmd *exec.Cmd) error {
17+
if cmd == nil || cmd.Process == nil {
18+
return nil
19+
}
20+
21+
// Send SIGTERM to stop process gracefully
22+
if err := cmd.Process.Signal(syscall.SIGTERM); err != nil {
23+
// If SIGTERM fails, try SIGINT (Ctrl+C)
24+
cmd.Process.Signal(syscall.SIGINT)
25+
}
26+
27+
return nil
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//go:build windows
2+
3+
package terminal
4+
5+
import (
6+
"os"
7+
"os/exec"
8+
)
9+
10+
// setSysProcAttr sets Windows-specific process attributes (no-op on Windows)
11+
func setSysProcAttr(cmd *exec.Cmd) {
12+
// No equivalent on Windows - process groups work differently
13+
}
14+
15+
// stopProcess kills the process on Windows
16+
func stopProcess(cmd *exec.Cmd) error {
17+
if cmd == nil || cmd.Process == nil {
18+
return nil
19+
}
20+
21+
// On Windows, just kill the process directly
22+
return cmd.Process.Signal(os.Kill)
23+
}

internal/terminal/terminal.go

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

1110
"github.com/kartoza/kartoza-screencaster/internal/config"
1211
)
@@ -111,8 +110,8 @@ func (r *Recorder) Start(opts RecorderOptions) error {
111110
r.cmd.Stdout = os.Stdout
112111
r.cmd.Stderr = os.Stderr
113112

114-
// Start in a new process group so we can signal it
115-
r.cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
113+
// Set platform-specific process attributes
114+
setSysProcAttr(r.cmd)
116115

117116
if err := r.cmd.Start(); err != nil {
118117
return fmt.Errorf("failed to start asciinema: %w", err)
@@ -133,11 +132,8 @@ func (r *Recorder) Stop() error {
133132
return nil
134133
}
135134

136-
// Send SIGTERM to stop asciinema gracefully
137-
if err := r.cmd.Process.Signal(syscall.SIGTERM); err != nil {
138-
// If SIGTERM fails, try SIGINT (Ctrl+C)
139-
r.cmd.Process.Signal(syscall.SIGINT)
140-
}
135+
// Stop process using platform-specific method
136+
stopProcess(r.cmd)
141137

142138
// Wait for process to finish
143139
r.cmd.Wait()

0 commit comments

Comments
 (0)