cp and mv behaviour on a busy binary file
Solène
solene at perso.pw
Mon Jul 11 14:41:58 UTC 2016
Hello,
I found a not coherent behaviour when overwriting a busy binary and I
would like an explanation on this.
When overwriting a busy binary file, without -f flag, cp won't copy the
file over the executable while mv will ask if you really want to
overwrite it.
When using -f, they act the same, the file get overwrited.
Example here :
shell at example : cat test.c
#include <unistd.h>
int main() {
sleep(1000);
return 0;
}
shell at example : clang test.c
shell at example : ./a.out & <- I start the executable
[1] 83540
shell at example : touch file
shell at example : cp file a.out
cp: a.out: Text file busy <- cp don't agree
shell at example : mv file a.out
override rwxr-xr-x solene/solene for a.out? (y/n [n]) y <--- mv asks
Kind regards
More information about the freebsd-questions
mailing list