reload
reload copied to clipboard
Not supported by windows error
Hello. Thanks for writing this library, it is very useful. I am using these library for both my mac and linux versions of my cmd app. Unfortunately it looks like it does not support windows. Do you have any workaround for reloading in windows? Wish you all the best, Mario
Do you get an error? Or what happens when you try to use it on Windows?
I don't have a Windows machine myself, so bit hard to look at it. The quickest way to get it running is to take a look at the code and see if you can fix it. It's not very complex so hopefully shouldn't be too hard.
Hello. Thanks for writing this library, it is very useful. I am using these library for both my mac and linux versions of my cmd app. Unfortunately it looks like it does not support windows. Do you have any workaround for reloading in windows? Wish you all the best, Mario
hello,did you find a solution? library not working for windows
No @0xhex, I don't have a Windows machine to test myself, and the OP never got back with an error. What error are you getting?
No @0xhex, I don't have a Windows machine to test myself, and the OP never got back with an error. What error are you getting?
Here the error

Thanks! It looks like syscall.Exec() isn't supported on Windows:
func Exec(argv0 string, argv []string, envv []string) (err error) {
return EWINDOWS
}
Where EWINDOWS is the not supported by windows error.
I'm not sure what a good solution would be; I don't think there is an equivalent "replace current process" system call on Windows, although there probably are ways around it, see e.g. https://github.com/golang/go/issues/30662 as well as the same fix they did for kubectl.
Like I said, I don't really have a Windows machine so I can't test this, but happy to accept patches.
Thanks! It looks like
syscall.Exec()isn't supported on Windows:func Exec(argv0 string, argv []string, envv []string) (err error) { return EWINDOWS }Where
EWINDOWSis thenot supported by windowserror.I'm not sure what a good solution would be; I don't think there is an equivalent "replace current process" system call on Windows, although there probably are ways around it, see e.g. golang/go#30662 as well as the same fix they did for kubectl.
Like I said, I don't really have a Windows machine so I can't test this, but happy to accept patches.
I can provide you a dedicated server windows if you want,this is so important to me
this code looks like working,i will back you about it
fmt.Println("test" + os.Args[0] + " __ " + os.Args[1])
time.Sleep(1 * time.Second)
cmd := exec.Command(os.Args[0], "0")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.Env = os.Environ()
err := cmd.Run()
if err == nil {
os.Exit(0)
}
Coolio, feel free to open a PR.
Not sure why that time.Sleep() is in there though? 🤔
Coolio, feel free to open a PR.
Not sure why that
time.Sleep()is in there though? 🤔
Ah,i forgot to remove it 👍 i use it in my project before reload just waiting 1 second
@0xhex thanks, the idea got me on the way, but a few things:
cmd.Runis blocking so the rest is not going to execute.cmd.Startis betteros.Exit(0)exits immediately the process. Instead I'm using something such asStopChan <- syscall.SIGINTto notify per signal and exits gracefully (and execute the remaining clean up functions). I'm not sure how this would integrate to this library asStopChanis part of my own program...
Hi everyone! Any news on this?
I've tried this tool for cross build and it doesn't work on Windows =(
I still don't have a Windows machine @RedStalker, so still waiting for a patch. In particular, need to be careful it replaces the process correctly and that no zombie processes are left behind.
any progress about it please?
@arp242 That code will not replace the process, but rather spawn a new one and wait for it to exit. It's the best you can do for windows, since it doesn't support replacing a process.
@0cv The blocking behaviour is crucial, since the it's not meant to continue executing. Although, it should probably forward the exit code from the error:
cmd := exec.Command(os.Args[0], "0")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.Env = os.Environ()
err := cmd.Run()
if err == nil {
os.Exit(0)
}
if exitError, isExit := err.(exec.ExitError); isExit {
os.Exit(exitError.ExitCode())
}
os.Exit(1)
@0xhex It doesn't seem like you did a PR for this?