Skip to content

Add Windows support#230

Open
ajw1980 wants to merge 1 commit into
aptible:mainfrom
ajw1980:windows-support
Open

Add Windows support#230
ajw1980 wants to merge 1 commit into
aptible:mainfrom
ajw1980:windows-support

Conversation

@ajw1980

@ajw1980 ajw1980 commented Jun 8, 2026

Copy link
Copy Markdown

Add Windows support

Closes #102

Adds cross-compilation and runtime support for Windows. Tested running as a Windows service with a real crontab firing on schedule.

Approach

Build tags are used only where a symbol literally doesn't exist on Windows and would cause a compile error regardless of code path (Setpgid, SIGUSR2, ForkExec, Wait4, SIGCHLD). Everything else uses runtime.GOOS to keep the number of new files minimal.

Three new files:

  • cron/unix.go / cron/windows.go — platform split for sysProcAttr() since Setpgid won't compile on Windows even in dead code
  • windows.go — all main package Windows stubs in one place: forkExec no-op, synthetic reloadSig sentinel, and a Windows-appropriate signalList

Four modified files:

  • reaper.go//go:build !windows tag; reloadSignal and signalList moved here for the Unix side
  • cron/cron.gosysProcAttr() call; runtime.GOOS to select -c vs -Command shell flag
  • crontab/crontab.goruntime.GOOS to default to powershell.exe on Windows instead of /bin/sh
  • main.gosyscall.SIGUSR2 replaced with reloadSignal throughout; syscall import removed

Platform notes

Default shell: powershell.exe with -Command. Override with SHELL= in your crontab as usual.

Crontab reload: SIGUSR2 can't be delivered to a Windows process externally so that path is a no-op on Windows. The -inotify flag works correctly via ReadDirectoryChangesW and is the recommended reload mechanism on Windows.

Process reaping: forkExec() is stubbed with logrus.Fatal. The reaper is only entered when os.Getpid() == 1, which is never true on Windows, so it's dead code in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release a Windows build

1 participant