uutils / uutils/coreutils

cp with backup is not able to replace an open .exe file

Open
#3,034 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P - Windows U - cp
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

For an exe file a.exe in dest folder, cp with any of the backup options like
cp -v --backup=numbered src/a.exe dest/a.exe
fails with error
The process cannot access the file because it is being used by another process. (os error 32)
(If relevant, on OS Windows)
Normally such a file could be manually replaced if the destination file is renamed first. Since a backup is also put in the same directory, maybe cp could also make a backup by renaming the file rather than just copying it?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing cp -v --backup=numbered src/a.exe dest/a.exe on Windows while the destination executable is open. Trace the backup and replacement handling for the cp command, then verify that backup-enabled replacement succeeds and preserves the destination backup without the sharing-violation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.