#5077: fix(windows): implement reliable gateway restart via schtasks helper
Cluster:
Gateway Restart Improvements
fixes #5065
Updated /restart command to skip unreliable SIGUSR1 signals on Windows, forcing a full process restart instead.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR changes `/restart` handling to avoid in-process `SIGUSR1` restarts on Windows (where signaling is unreliable) and instead trigger a full process restart. It introduces a Windows-specific restart path in `src/infra/restart.ts` that spawns a detached `cmd.exe` command chain using `schtasks`/`taskkill` to stop and relaunch the gateway scheduled task.
The command-session handler now selects between `SIGUSR1` scheduling vs. supervisor restart based on platform and listener presence, which keeps existing macOS/Linux behavior while making Windows use the new scheduled-task restart helper.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge, but the Windows restart command construction has a high-impact injection risk and should be addressed first.
- Most changes are localized and align with the stated goal (avoid SIGUSR1 on Windows). However, the new `cmd.exe /C` restart chain interpolates task/profile-derived strings into a shell command, which can break in edge cases and is a security footgun if those values are attacker-influenced. There are also unused imports that may break CI depending on lint settings.
- src/infra/restart.ts
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#7128: feat: add gateway.restart RPC for graceful in-process restart
by AkashaBot · 2026-02-02
80.2%
#16170: fix: restart service manager after update.run
by Swader · 2026-02-14
79.2%
#19504: fix(gateway): avoid stale running status from Windows Scheduled Task
by Fologan · 2026-02-17
78.4%
#5496: Fix: Windows path separators stripped in Gateway scheduled task
by giuliozelante · 2026-01-31
77.7%
#20355: fix(gateway): enforce commands.restart guard for config.apply and c...
by Clawborn · 2026-02-18
76.7%
#9112: Fix: Prevent double SIGUSR1 restart on model switch
by vishaltandale00 · 2026-02-04
76.1%
#13408: fix(gateway): skip SIGUSR1 restart in config.patch for noop reload ...
by rwmjhb · 2026-02-10
75.1%
#12953: fix: defer gateway restart until all replies are sent
by zoskebutler · 2026-02-10
75.0%
#9250: Fix: Add shell:true for Windows .cmd files to prevent spawn EINVAL ...
by vishaltandale00 · 2026-02-05
74.3%
#5046: schtasks: add helpful hint for 'stub received bad data' error
by shayan919293 · 2026-01-31
73.9%