[darcs-devel] darcs patch: atexit

David Roundy droundy at abridgegame.org
Tue Jan 25 03:21:26 PST 2005


On Tue, Jan 25, 2005 at 09:54:27AM +0100, Tomasz Zielonka wrote:
> Hello!
> 
> Here's the atexit implementation for darcs.
> 
> The actions are called in reverse order of their registration. Exceptions
> thrown by actions are caught and reported, but remaining actions are
> still performed. Actions can't register new actions, any such event is
> reported - this is to prevent looping.

Looks nice!

> I'm not sure I placed with_atexit in the right place with respect to
> other wrappers.

The one potential problem I can see would be if we're in a sigPIPE
situation, and I don't really know enough about how such things would work
to know if it would be a problem.  I'm just worried as to what would happen
if your hPutStrLn's to stderr themselves failed--it doesn't seem that they
are getting caught, so your exception handler itself could throw an
exception.  You could try running

darcs (a test command that uses atexit, and creates lots of output) 2>&1 | less

and see if killing less (or exiting the less with 'q') can cause darcs to
fail to clean up after itself.  That's my only idea as to how one could
(perhaps) break this code.
-- 
David Roundy
http://www.darcs.net




More information about the darcs-devel mailing list