Thread View: comp.sys.acorn.tech
1 messages
1 total messages
Started by Pete Goodwin
Thu, 06 Aug 1992 21:55
Re: Error trapping in C
Author: Pete Goodwin
Date: Thu, 06 Aug 1992 21:55
Date: Thu, 06 Aug 1992 21:55
33 lines
2227 bytes
2227 bytes
In article <1992Aug6.191108.1@vxdesy.desy.de>, burke@vxdesy.desy.de writes... >What do you need to do to make a C program bomb-proof? You obviously have to >catch SIGSTAK, but is it possible to get SIGINT or SIGTERM? If so, how? The C >manual isn't very forthcoming about signals. Also, does wimpt_noerr() stop the >program with exit() or abort()? The answer, it seems, is you can't. If you use malloc and free you can't catch the immortal 'malloc failure...' or 'free failure...'. On desktop applications you effectively DON'T SEE these messages. Your application simply exits without warning. Both these should signal _something_! Trouble is they don't! I started using heap_alloc and heap_free, simply because if either detect an error you get an error dialog box. The disadvantage is heap relies on flex, which seems to bump the wimpslot up a little. > Secondly, what should I do after a signal? Presumably a longjmp to the main >routine is the best bet, but what then - after a SIGSTAK, will it be safe to >call saveas()? Or I could save to an internal file and then quit, but what if >the save fails? Or I could put up a message and just go back to polling, but >will all the internal data structures be intact? (and you may just get SIGSTAK >again anyway). Acorn are always going on about how you shouldn't die with >unsaved data, and then they give you a system whose response to running out of >memory is to collapse with a backtrace, and no guidance on how to do it >better :-( Any ideas? If you read the ANSI standard, you'll see you need to do a longjmp to some point. This works, but the next error is fatal unless you reestablish the trap handlers again... Pete Goodwin goodwin@system.enet.dec.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads