Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 1079:e4c6a0dd5c2b legacy-trunk
* bltinmodule.c: added built-in function cmp(a, b)
* flmodule.c: added {do,check}_only_forms to fl's list of functions;
and don't print a message when an unknown object is returned.
* pythonrun.c: catch SIGHUP and SIGTERM to do essential cleanup.
* Made jpegmodule.c smaller by using getargs() and mkvalue() consistently.
* Increased parser stack size to 500 in parser.h.
* Implemented custom allocation of stack frames to frameobject.c and
added dynamic stack overflow checks (value stack only) to ceval.c.
(There seems to be a bug left: sometimes stack traces don't make sense.)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sun, 18 Oct 1992 18:53:57 +0000 |
| parents | 2c0432fcc270 |
| children | 1cabc2b6c970 |
line wrap: on
line diff
--- a/Python/pythonrun.c Sun Oct 18 17:09:59 1992 +0000 +++ b/Python/pythonrun.c Sun Oct 18 18:53:57 1992 +0000 @@ -38,10 +38,21 @@ #include "pythonrun.h" #include "import.h" +#ifdef unix +#define HANDLE_SIGNALS +#endif + +#ifdef HANDLE_SIGNALS +#include <signal.h> +#include "sigtype.h" +#endif + extern char *getpythonpath(); extern grammar gram; /* From graminit.c */ +void initsigs(); /* Forward */ + int debugging; /* Needed by parser.c */ int verbose; /* Needed by import.c */ @@ -67,10 +78,10 @@ initsys(); initcalls(); /* Configuration-dependent initializations */ - - initintr(); /* For intrcheck() */ setpythonpath(getpythonpath()); + + initsigs(); /* Signal handling stuff, including initintr() */ } /* Parse input from a file and execute it */ @@ -372,8 +383,7 @@ #endif void -goaway(sts) - int sts; +cleanup() { object *exitfunc = sysget("exitfunc"); @@ -395,6 +405,13 @@ } flushline(); +} + +void +goaway(sts) + int sts; +{ + cleanup(); #ifdef USE_THREAD @@ -433,6 +450,30 @@ /*NOTREACHED*/ } +#ifdef HANDLE_SIGNALS +SIGTYPE +sighandler(sig) + int sig; +{ + signal(sig, SIG_DFL); /* Don't catch recursive signals */ + cleanup(); /* Do essential clean-up */ + kill(getpid(), sig); /* Pretend the signal killed us */ + /*NOTREACHED*/ +} +#endif + +void +initsigs() +{ + initintr(); +#ifdef HANDLE_SIGNALS + if (signal(SIGHUP, SIG_IGN) != SIG_IGN) + signal(SIGHUP, sighandler); + if (signal(SIGTERM, SIG_IGN) != SIG_IGN) + signal(SIGTERM, sighandler); +#endif +} + #ifdef TRACE_REFS /* Ask a yes/no question */
