{"record":{"id":"f86d9536a10c21e4","repo":"lima-vm/lima","slug":"unimplemented-f86d95","errorCode":null,"errorMessage":"unimplemented","messagePattern":"unimplemented","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/osutil/osutil_windows.go","lineNumber":61,"sourceCode":"}\n\n// ProcessAlive reports whether the process with the given PID is still running.\nfunc ProcessAlive(pid int) bool {\n\th, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))\n\tif err != nil {\n\t\treturn false\n\t}\n\tvar exitCode uint32\n\terr = windows.GetExitCodeProcess(h, &exitCode)\n\t_ = windows.CloseHandle(h)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn exitCode == 259 // STILL_ACTIVE\n}\n\nfunc Dup2(_ int, _ syscall.Handle) error {\n\treturn errors.New(\"unimplemented\")\n}\n\nfunc SignalName(sig os.Signal) string {\n\tswitch sig {\n\tcase syscall.SIGINT:\n\t\treturn \"SIGINT\"\n\tcase syscall.SIGTERM:\n\t\treturn \"SIGTERM\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"Signal(%d)\", sig)\n\t}\n}\n\nfunc Sysctl(_ context.Context, _ string) (string, error) {\n\treturn \"\", errors.New(\"sysctl: unimplemented on Windows\")\n}\n\nfunc IsEACCES(err error) bool {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/osutil/osutil_windows.go#L43-L79","documentation":"The Windows build of osutil provides a Dup2 stub that always returns this 'unimplemented' error, because Windows has no file-descriptor duplication syscall equivalent exposed through syscall.Dup2. The function exists only to satisfy the cross-platform API surface.","triggerScenarios":"Any caller invoking osutil.Dup2 on a Windows build — there is no code path that succeeds; every call returns errors.New(\"unimplemented\").","commonSituations":"Code shared across platforms calling Dup2 (e.g. to redirect stderr to a log file, typical in daemon/log-rotation code) being compiled and run on Windows; cross-compiling Unix daemon logic to Windows.","solutions":["Do not call Dup2 on Windows; gate the call behind runtime.GOOS checks or build tags.","Use Windows-appropriate redirection instead (SetStdHandle / os.Process attributes like Stderr in os/exec).","If redirecting logs, reopen the log file and reassign os.Stderr via a Windows-supported mechanism."],"exampleFix":"// before\nosutil.Dup2(int(f.Fd()))\n// after\nif runtime.GOOS != \"windows\" {\n    _ = osutil.Dup2(int(f.Fd()))\n} else {\n    // use SetStdHandle or exec.Cmd Stderr wiring\n}","handlingStrategy":"type-guard","validationCode":"if runtime.GOOS == \"windows\" {\n    // Dup2 is unimplemented; use exec.Cmd Stderr or SetStdHandle instead\n}","typeGuard":"func dup2Supported() bool { return runtime.GOOS != \"windows\" }","tryCatchPattern":"if err := osutil.Dup2(fd); err != nil {\n    if err.Error() == \"unimplemented\" && runtime.GOOS == \"windows\" {\n        return redirectToStdHandle(fd) // windows-specific path\n    }\n    return err\n}","preventionTips":["Never call Dup2 in code paths compiled for windows (use build tags)","Use os/exec Cmd.Std* wiring for fd redirection instead of Dup2","Add a unit test asserting no Dup2 call sites execute on windows"],"tags":["windows","unimplemented","dup2","portability"],"backgroundTag":"unimplemented-on-windows","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}