in reply to Re^2: how to close all files
in thread how to close all files

Why do you care about flushing the last write? Presumably the reason for the closes is to leave the control of all the open files to the parent.

As for what JavaFan suggests, keeping track of open file descriptors when you know you might need to close them all at the same time is painful, but probably the wisest. Simply finding the open descriptors and closing them may or may not be a good idea. Some open descriptors may be within the context of included modules, and simply closing the descriptor without invoking the 'normal' close/disconnect/exit method might not produce the expected/desired results.