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

Properly close all open files on exit #121

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion gap/io.gi
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@
IO.OpenFiles := Set([]);
InstallAtExit(function()
local file;
for file in IO.OpenFiles do
# CAUTION: Calling IO_Close below removes the file from
# IO.OpenFiles, so iterating over IO.OpenFiles in a for-loop
# would skip every second file!
while Length(IO.OpenFiles) > 0 do
file := IO.OpenFiles[1];

Check warning on line 72 in gap/io.gi

View check run for this annotation

Codecov / codecov/patch

gap/io.gi#L71-L72

Added lines #L71 - L72 were not covered by tests
if IsBound(file!.dowaitpid) then
Unbind(file!.dowaitpid);
fi;
# this call removes the file from IO.OpenFiles
IO_Close(file);
od;
end
Expand Down