|
|
Subscribe / Log in / New account

Zeuthen: Writing a C library, part 1

Zeuthen: Writing a C library, part 1

Posted Jun 28, 2011 15:48 UTC (Tue) by nix (subscriber, #2304)
In reply to: Zeuthen: Writing a C library, part 1 by cmccabe
Parent article: Zeuthen: Writing a C library, part 1

I wonder if David was a Perl programmer before he was a C programmer? 'die on error' actually makes sense in Perl, because library users can trap it. But they can't trap abort(). You should abort() about as often as you BUG_ON() in the kernel: when you can't continue, your internal state is blown and can't be fixed, and the world is ending. And nothing you can predict (e.g. OOM) should lead you into such a state.


to post comments

Zeuthen: Writing a C library, part 1

Posted Jun 28, 2011 16:18 UTC (Tue) by HelloWorld (guest, #56129) [Link]

> But they can't trap abort().
They can use longjump in the SIGABRT signal handler. But that probably doesn't make much of a difference, as a library that calls abort probably won't free allocated resources before it does, resulting in resource leaks.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds