On 4 November 2011 19:24, Andrew Myers asm198@gmail.com wrote:
Is this a problem in Lisp? I know in C that's an issue since you're just calling close on an integer but I had thought lisp would handle that more gracefully. Although I guess the behavior isn't specified since saving an image is outside the spec?
Well...
It is possible that your implementation keeps track of all open "system" streams, and cleans up such objects on its own when you save a core. I would not know if it does that, but I would not rely on it either.
If it doesn't do that, at some point closing a socket means calling close(2) or equivalent system call on the file descriptor / handle -- which means is risky on init.
The problem with cleaning up _before_ saving the image is that you can't use the image any more. I was hoping to have a solution that didn't require an exit and restart every time an image was dumped.
Unless you're on Windows, the time honored solution is to fork(2) before saving.
If you can't do that, then digging into implementation specifics you may be able to nuke the connections without closing the file descriptors / handles.
...or you can just live dangerously. Just be aware that you're doing something potentially tricksy, so that if and when something mysteriously breaks down the road, you know where to look. :)
Cheers,
-- Nikodemus