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

Close OutputFile #17

Closed
wkschwartz opened this issue Sep 26, 2016 · 1 comment
Closed

Close OutputFile #17

wkschwartz opened this issue Sep 26, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@wkschwartz
Copy link
Owner

wkschwartz commented Sep 26, 2016

If a client passes a non-nil OutputFile *os.File to the Pigosat constructor, the constructor opens a *C.FILE and leaves it open, passing it to Picosat. Since we create the *C.FILE in the constructor, we should close it in the destructor. This may require holding onto the *C.FILE in the Pigosat object (in a private data member), to be closed in Pigosat.delete. Make sure to set this data member to nil when delete is done with it.

We should test that closing the *C.FILE does not close the underlying *os.File. From what I can tell from the manpage for fclose, fclose(*FILE) only dissociates the particular instance of *FILE from the underlying file descriptor, so closing one *FILE doesn't close the descriptor for other open instances of that descriptor.

@wkschwartz
Copy link
Owner Author

Turns out calling c.fclose(outputFile) actually does close the underlying file descriptor. The up shot is that we cannot close the *C.FILE reference to OutputFile without closing the underlying file. It's better for the client to do this.

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

No branches or pull requests

1 participant