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

File (descriptor) not closed upon deletion #134

Open
idanya opened this issue Feb 8, 2018 · 3 comments
Open

File (descriptor) not closed upon deletion #134

idanya opened this issue Feb 8, 2018 · 3 comments

Comments

@idanya
Copy link

idanya commented Feb 8, 2018

I am tailing a file that at some point (while tailing) gets deleted. I don't use reopen option, when the file is deleted I expect the tail to stop. The tail really stops, but I can see the file descriptor is not.
when running lsof I can see all files tailed with a "(deleted)" string at the end.

Seems weird as tailFileSync starts with defer tail.close() and when the file gets deleted an ErrStop is raised and should just cause a return (triggering the defer).
What am I missing?

@lelikg
Copy link

lelikg commented Feb 8, 2018

+1

@zhoufang-joe
Copy link

zhoufang-joe commented Oct 24, 2018

The tail only detect changes after reaching to the EOF. If you do not consume the tail.Lines chan, the sendLine func will be blocked. The tail may not be able to reach to the EOF, thus cannot detect the file deletion change.

@idanya
Copy link
Author

idanya commented Oct 27, 2018

I can see that sendLine is blocking with the chan, but assuming I will eventually process all chan lines (and I do), the tail loop will try to read the next line and will fail, causing the loop to end with tail.Killf(). This should close the file descriptor/reader, isn't it?

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

No branches or pull requests

3 participants