From 166d62215b31f9e3e1f8d2d8e01822b746a47a12 Mon Sep 17 00:00:00 2001 From: metif12 Date: Sat, 17 Oct 2026 12:23:52 +0330 Subject: [PATCH] timeout: take the process by mutable pointer, so the Windows build works again main does not build timeout. The tip commit c6cbc320b6 ("timeout: fix errors") changed every terminate_process to take the process by value, but left the two calls that mutate it: src/timeout/timeout_windows.c.v:13:3: error: `p` is immutable, declare it with `mut` to make it mutable src/timeout/timeout_windows.c.v:15:3: error: `p` is immutable, declare it with `mut` to make it mutable fn terminate_process(p os.Process, ...) { if sig_num == 15 { p.signal_term() } else { p.signal_kill() } } Reproduced on c6cbc320b6: `v -o timeout.exe src/timeout` fails with exactly those two errors, so the Windows build of timeout is broken on main. CI has been failing inside the V bootstrap before it reaches any of this, which is why it went unnoticed. The comment already sitting above that function says why a value cannot work - "A pointer, because signalling a process changes it. Passing it by value ... made the compiler reference it for us and then reject that as deprecated automatic referencing." - so the signature is what has to move back, not the comment. All three platform variants have to agree, because timeout.v calls whichever one the target selects from a single shared call site. So all three take `mut p &os.Process` and both call sites pass `mut &p`, which is what the tree had before c6cbc320b6 and is the only combination of those two choices that compiles. Verified after the change: timeout builds, and src/timeout passes 1/1 with a real GNU timeout on PATH to compare against. v fmt -verify is clean on all four files. The diff is five lines - three signatures and two call sites. --- src/timeout/timeout.v | 4 ++-- src/timeout/timeout_default.c.v | 2 +- src/timeout/timeout_nix.c.v | 2 +- src/timeout/timeout_windows.c.v | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/timeout/timeout.v b/src/timeout/timeout.v index 943685d8..3f75cdf2 100644 --- a/src/timeout/timeout.v +++ b/src/timeout/timeout.v @@ -249,7 +249,7 @@ fn handle_timeout(mut p os.Process, kill_after_ms i64, signal string, preserve_s if verbose { eprintln('${app_name}: sending signal ${signal} to command') } - terminate_process(p, sig_num, !foreground) + terminate_process(mut &p, sig_num, !foreground) if kill_after_ms > 0 { kill_start := time.now() @@ -263,7 +263,7 @@ fn handle_timeout(mut p os.Process, kill_after_ms i64, signal string, preserve_s if verbose { eprintln('${app_name}: sending signal KILL to command') } - terminate_process(p, 9, !foreground) + terminate_process(mut &p, 9, !foreground) } return handle_process_exit(mut p, preserve_status, 124) } diff --git a/src/timeout/timeout_default.c.v b/src/timeout/timeout_default.c.v index 48f756b6..a912be6b 100644 --- a/src/timeout/timeout_default.c.v +++ b/src/timeout/timeout_default.c.v @@ -4,7 +4,7 @@ fn setup_process_group(p os.Process, foreground bool) { // Fallback } -fn terminate_process(p os.Process, sig_num int, process_group bool) { +fn terminate_process(mut p &os.Process, sig_num int, process_group bool) { // Fallback: try to kill the process p.signal_kill() } diff --git a/src/timeout/timeout_nix.c.v b/src/timeout/timeout_nix.c.v index 00f43499..5a2d001c 100644 --- a/src/timeout/timeout_nix.c.v +++ b/src/timeout/timeout_nix.c.v @@ -12,7 +12,7 @@ fn setup_process_group(p os.Process, foreground bool) { } } -fn terminate_process(p os.Process, sig_num int, process_group bool) { +fn terminate_process(mut p &os.Process, sig_num int, process_group bool) { pid := if process_group { -p.pid } else { p.pid } C.kill(pid, sig_num) } diff --git a/src/timeout/timeout_windows.c.v b/src/timeout/timeout_windows.c.v index c0c688a9..a035f983 100644 --- a/src/timeout/timeout_windows.c.v +++ b/src/timeout/timeout_windows.c.v @@ -7,7 +7,7 @@ fn setup_process_group(p os.Process, foreground bool) { // A pointer, because signalling a process changes it. Passing it by value, as the // nix version can, made the compiler reference it for us and then reject that as // deprecated automatic referencing. -fn terminate_process(p os.Process, sig_num int, process_group bool) { +fn terminate_process(mut p &os.Process, sig_num int, process_group bool) { // TERM, Windows doesn't seem to support signals like Unixes does if sig_num == 15 { p.signal_term()