Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Windows locks executing files #7

Open
krzysztofantczak opened this issue May 9, 2016 · 4 comments
Open

[Bug] Windows locks executing files #7

krzysztofantczak opened this issue May 9, 2016 · 4 comments
Labels

Comments

@krzysztofantczak
Copy link

Hi,

It seems that something is wrong with the way it works under windows. When its trying to move a file:

The process cannot access the file because it is being used by another process

Any ideas how can i fix it?

@jpillora
Copy link
Owner

jpillora commented May 9, 2016

Sorry, I didn't add the Windows support so I'm unable to help!
On Mon, 9 May 2016 at 6:44 PM Krzysztof Antczak notifications@github.com
wrote:

Hi,

It seems that something is wrong with the way it works under windows. When
its trying to move a file:

The process cannot access the file because it is being used by another process

Any ideas how can i fix it?


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#7

@tgulacsi
Copy link
Contributor

@krzysztofantczak Windows locks executing files, so I don't know an easy solution. Maybe same black-magic dancing with renames and copies could work:
0. Assume we've been started as a.exe

  1. download as a-upd.exe
  2. try to execute a-upd.exe with OVERSEER_BIN_UPD env var (see "sanity check")
  3. exec (replace current process with the new one - if such exists in Windows) a-upd.exe with some env param to notify this is an intermediate step;
  4. in this intermediate step, copy a-upd.exe to a.exe
  5. exec a.exe

(AFAIK now steps 1, 2, 5 are in action).

@jpillora jpillora added the bug label May 24, 2016
@jpillora jpillora changed the title Windows support [Bug] Windows locks executing files May 24, 2016
@elvarb
Copy link

elvarb commented Feb 1, 2018

Moving a file is impossible, but it is possible to rename the running file. Solving this would always requiring restarting the process.

  1. Rename bin.exe to bin_oldver.exe
  2. Download new bin to bin.exe
  3. Restart running bin.exe with the new bin.exe

@hellowzsg
Copy link

Problems solved( rename), if still doesn't work, make sure the src and dst in the same disk drive.
You can Modify like this,
https://github.com/tgulacsi/overseer/blob/fcf3e6b7d6c0cb9097be23e7191459e68b6a5f1b/proc_master.go#L22
var tmpBinPath = filepath.Join(os.TempDir(), "overseer-"+token()) ==>
var tmpBinPath = filepath.Join("./", "overseer-"+token())

But, there is another problems , the go(1.18) is not support for fileconn in window. https://github.com/golang/go/issues/9503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants