[pure-lang-svn] SF.net SVN: pure-lang:[473] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-08-12 13:44:48
|
Revision: 473 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=473&view=rev Author: agraef Date: 2008-08-12 13:44:56 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Add handlers for POSIX termination signals. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/pure.cc Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-08-12 13:28:56 UTC (rev 472) +++ pure/trunk/ChangeLog 2008-08-12 13:44:56 UTC (rev 473) @@ -1,5 +1,9 @@ 2008-08-12 Albert Graef <Dr....@t-...> + * pure.cc (main): Set up handlers for standard POSIX termination + signals, mapping these to orderly Pure exceptions of the form + 'signal SIG'. + * interpreter.cc (builtin_codegen), runtime.cc(bigint_div, bigint_mod): Handle division by zero by throwing a 'signal SIGFPE' exception. Previously, these would just bail out with an unhandled Modified: pure/trunk/pure.cc =================================================================== --- pure/trunk/pure.cc 2008-08-12 13:28:56 UTC (rev 472) +++ pure/trunk/pure.cc 2008-08-12 13:44:56 UTC (rev 473) @@ -162,7 +162,7 @@ return matches; } -static void sigint_handler(int sig) +static void sig_handler(int sig) { interpreter::brkflag = sig; } @@ -185,13 +185,32 @@ // This is used in advisory stack checks. interpreter::baseptr = &base; // make sure that SIGPIPE is ignored -#ifndef _WIN32 + /* Set up handlers for all standard POSIX termination signals (except + SIGKILL which is unmaskable). SIGPIPE is ignored by default, all others + are mapped to Pure exceptions of the form 'signal SIG', so that they can + be caught with 'catch' or safely return us to the interpreter's + interactive command line. */ +#ifdef SIGHUP + signal(SIGHUP, sig_handler); +#endif +#ifdef SIGINT + signal(SIGINT, sig_handler); +#endif +#ifdef SIGPIPE signal(SIGPIPE, SIG_IGN); #endif - /* Set up a SIGINT handler which throws a Pure exception, so that we safely - return to the interpreter's interactive command line when the user - interrupts a computation. */ - signal(SIGINT, sigint_handler); +#ifdef SIGALRM + signal(SIGALRM, sig_handler); +#endif +#ifdef SIGTERM + signal(SIGTERM, sig_handler); +#endif +#ifdef SIGUSR1 + signal(SIGUSR1, sig_handler); +#endif +#ifdef SIGUSR2 + signal(SIGUSR2, sig_handler); +#endif // set up an exit function which saves the history if needed atexit(exit_handler); // set the system locale This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |