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

os: "os.RemoveAll" sometimes returns error "remove files: directory not empty" #23452

Closed
cwen0 opened this issue Jan 15, 2018 · 4 comments
Closed

Comments

@cwen0
Copy link

@cwen0 cwen0 commented Jan 15, 2018

I use os.RemoveAll remove dir, and program sometimes return "remove pd: directory not empty"

drwx------. 5 xxx xxx 4.0K Jan 16 03:22 pd

What version of Go are you using (go version)?

go version: go version go1.9.2 linux/amd64

What operating system and processor architecture are you using (go env)?

os : CentOS Linux release 7.3.1611 (Core)
kernel: 3.10.0-514.el7

What did you do?

What did you expect to see?

I expect os.RemoveAll to delete all the files

What did you see instead?

Sometimes the dir is not deleted and then an error is thrown.

Thanks!

@cwen0 cwen0 changed the title `os.RemoveAll` sometimes returns error "remove files: directory not empty" "os.RemoveAll" sometimes returns error "remove files: directory not empty" Jan 15, 2018
@davecheney

This comment has been minimized.

Copy link
Contributor

@davecheney davecheney commented Jan 15, 2018

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 15, 2018

Is it possible that some other goroutine, or some other process, is creating entries in the directory as you are trying to delete it?

@cwen0

This comment has been minimized.

Copy link
Author

@cwen0 cwen0 commented Jan 16, 2018

@ianlancetaylor you are true, I just found this problem, Thanks. Another process is using this dir. I delete this directory for the purpose of letting the program exit. When os.RemoveAll remove all other files in this dir and will exec Remove(path), the process creates a new file in this dir to cause this error.
@davecheney @ianlancetaylor Thanks.

@davecheney

This comment has been minimized.

Copy link
Contributor

@davecheney davecheney commented Jan 16, 2018

Thanks for confirming. Closing

@davecheney davecheney closed this Jan 16, 2018
@mikioh mikioh changed the title "os.RemoveAll" sometimes returns error "remove files: directory not empty" os: "os.RemoveAll" sometimes returns error "remove files: directory not empty" Jan 16, 2018
@golang golang locked and limited conversation to collaborators Jan 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.