Skip to content

Commit 4acc074

Browse files
committed
fix: Windows build failure due to missing SIGWINCH
Move SIGWINCH terminal resize handler into platform-specific winchControl() function. Unix version handles resize via syscall.SIGWINCH, Windows version returns nil (no resize).
1 parent a813f3f commit 4acc074

3 files changed

Lines changed: 38 additions & 25 deletions

File tree

sandbox/incus/exec.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import (
66
"fmt"
77
"io"
88
"os"
9-
"os/signal"
109
"strings"
1110
"time"
1211

13-
"github.com/gorilla/websocket"
1412
"github.com/lxc/incus/v6/shared/api"
1513
"golang.org/x/term"
1614

@@ -175,27 +173,7 @@ func (i *Incus) Console(ctx context.Context, name string, opts sandbox.ConsoleOp
175173
Stdout: os.Stdout,
176174
Stderr: os.Stderr,
177175
DataDone: dataDone,
178-
Control: func(conn *websocket.Conn) {
179-
// Handle SIGWINCH for terminal resize.
180-
ch := make(chan os.Signal, 1)
181-
signal.Notify(ch, sigWINCH())
182-
defer signal.Stop(ch)
183-
184-
for range ch {
185-
w, h, err := term.GetSize(fd)
186-
if err != nil {
187-
continue
188-
}
189-
msg := api.InstanceExecControl{
190-
Command: "window-resize",
191-
Args: map[string]string{
192-
"width": fmt.Sprintf("%d", w),
193-
"height": fmt.Sprintf("%d", h),
194-
},
195-
}
196-
_ = conn.WriteJSON(msg)
197-
}
198-
},
176+
Control: winchControl(fd),
199177
}
200178

201179
op, err := i.server.ExecInstance(full, execPost, args)

sandbox/incus/signal_unix.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,35 @@
33
package incus
44

55
import (
6+
"fmt"
67
"os"
8+
"os/signal"
79
"syscall"
10+
11+
"github.com/gorilla/websocket"
12+
"github.com/lxc/incus/v6/shared/api"
13+
"golang.org/x/term"
814
)
915

10-
func sigWINCH() os.Signal {
11-
return syscall.SIGWINCH
16+
func winchControl(fd int) func(*websocket.Conn) {
17+
return func(conn *websocket.Conn) {
18+
ch := make(chan os.Signal, 1)
19+
signal.Notify(ch, syscall.SIGWINCH)
20+
defer signal.Stop(ch)
21+
22+
for range ch {
23+
w, h, err := term.GetSize(fd)
24+
if err != nil {
25+
continue
26+
}
27+
msg := api.InstanceExecControl{
28+
Command: "window-resize",
29+
Args: map[string]string{
30+
"width": fmt.Sprintf("%d", w),
31+
"height": fmt.Sprintf("%d", h),
32+
},
33+
}
34+
_ = conn.WriteJSON(msg)
35+
}
36+
}
1237
}

sandbox/incus/signal_windows.go

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 incus
4+
5+
import "github.com/gorilla/websocket"
6+
7+
// winchControl returns nil on Windows where SIGWINCH does not exist.
8+
func winchControl(_ int) func(*websocket.Conn) {
9+
return nil
10+
}

0 commit comments

Comments
 (0)