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

Bad file descriptor when opening file after USR2 #25

Open
geoffgarside opened this issue Mar 26, 2015 · 1 comment
Open

Bad file descriptor when opening file after USR2 #25

geoffgarside opened this issue Mar 26, 2015 · 1 comment

Comments

@geoffgarside
Copy link

I'm experiencing an odd issue after issuing a USR2 signal to my process. I've got an OnSIGHUP handler which opens some files and reloads data from them. On the first HUP after USR2 I get

read file.txt: bad file descriptor

if I HUP the process again it all works fine. I've been able to hack around this by setting a global variable after USR2 and if its the first HUP after a USR2 and doing

f, err := os.Open(os.DevNull)
if err == nil {
    defer f.Close()
}

and then running the code to reload the data from the files. Is this anything you've seen before, is there likely to be anything common I've not done correctly.

My use of goagain effectively matches the examples/simple/main.go example with the addition of the OnSIGHUP handler.

I'll try to replicate the issue with the simple example.

mtharp added a commit to mtharp/goagain that referenced this issue Jun 24, 2016
@mtharp
Copy link

mtharp commented Jun 24, 2016

Figured it out. Whenever the garbage collector runs it was closing the inherited FD a second time, either doing nothing or killing whatever file happened to be opened next after the restart. See pull request #28.

blamarvt added a commit to blamarvt/goagain that referenced this issue Jan 19, 2018
Fix double-close of FD on garbage collection (rcrowley#25)
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

2 participants