Is invoking exit(2) in a library the right thing to do?

Werner Koch wk at gnupg.org
Mon Nov 5 15:54:46 CET 2007


On Mon,  5 Nov 2007 13:37, md at Linux.IT said:

> I still do not consider calling exit(2) in a library acceptable under
> any condition.

So you want abort () instead?  I consider this a bad option in this case
because exit handlers would not be run.

Given the reluctance of many programmers to properly check error codes
and act accordingly, there is no choice in critical situation than to
terminate the process.  It was a design decision of the linux kernel to
always provide a /dev/random and it is a design decision of libgcrypt
not to return bad random number - in any case.

BTW, glibc also calls abort if it detects an internal inconsistency.


Salam-Shalom,

   Werner


-- 
Die Gedanken sind frei.  Auschnahme regelt ein Bundeschgesetz.




More information about the Gcrypt-devel mailing list