lichess-org/fishnet

No longer accepts input from terminal after restart with --auto-update on Windows

niklasf opened this issue · 2 comments

When a new release is available, the current binary is replaced with the updated version. But how to restart properly?

On Unix it's easy to use exec() to replace the current process image:
https://github.com/niklasf/fishnet/blob/329c3eeeaa49c88589baea57282d9305e3217d40/src/main.rs#L351

So far I was not able to find an equivalent on Windows.

https://github.com/niklasf/fishnet/blob/329c3eeeaa49c88589baea57282d9305e3217d40/src/main.rs#L359


Upstream question: jaemk/self_update#62

That looks like you are running exec inside the tokio runtime? Won't exec just never return, and you can potentially just keep stacking tokio runtimes on top of one another? I might be misunderstanding things.

It's the one from std::os::unix::process::CommandExt. Under the hood it uses the execvp syscall without forking, replacing the current process image instead of stacking a new one on top. All other threads should be destroyed by the operating system, not by properly shutting down tokio. So I guess it could leak some file descriptors, if any remain open at that point.