comparison 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
comparison
equal deleted inserted replaced
1078:245003c006a6 1079:e4c6a0dd5c2b
36 #include "eval.h" 36 #include "eval.h"
37 #include "ceval.h" 37 #include "ceval.h"
38 #include "pythonrun.h" 38 #include "pythonrun.h"
39 #include "import.h" 39 #include "import.h"
40 40
41 #ifdef unix
42 #define HANDLE_SIGNALS
43 #endif
44
45 #ifdef HANDLE_SIGNALS
46 #include <signal.h>
47 #include "sigtype.h"
48 #endif
49
41 extern char *getpythonpath(); 50 extern char *getpythonpath();
42 51
43 extern grammar gram; /* From graminit.c */ 52 extern grammar gram; /* From graminit.c */
53
54 void initsigs(); /* Forward */
44 55
45 int debugging; /* Needed by parser.c */ 56 int debugging; /* Needed by parser.c */
46 int verbose; /* Needed by import.c */ 57 int verbose; /* Needed by import.c */
47 58
48 /* Initialize all */ 59 /* Initialize all */
65 76
66 initbuiltin(); /* Also initializes builtin exceptions */ 77 initbuiltin(); /* Also initializes builtin exceptions */
67 initsys(); 78 initsys();
68 79
69 initcalls(); /* Configuration-dependent initializations */ 80 initcalls(); /* Configuration-dependent initializations */
70
71 initintr(); /* For intrcheck() */
72 81
73 setpythonpath(getpythonpath()); 82 setpythonpath(getpythonpath());
83
84 initsigs(); /* Signal handling stuff, including initintr() */
74 } 85 }
75 86
76 /* Parse input from a file and execute it */ 87 /* Parse input from a file and execute it */
77 88
78 int 89 int
370 #ifdef USE_THREAD 381 #ifdef USE_THREAD
371 extern int threads_started; 382 extern int threads_started;
372 #endif 383 #endif
373 384
374 void 385 void
375 goaway(sts) 386 cleanup()
376 int sts;
377 { 387 {
378 object *exitfunc = sysget("exitfunc"); 388 object *exitfunc = sysget("exitfunc");
379 389
380 if (exitfunc) { 390 if (exitfunc) {
381 object *arg; 391 object *arg;
393 print_error(); 403 print_error();
394 } 404 }
395 } 405 }
396 406
397 flushline(); 407 flushline();
408 }
409
410 void
411 goaway(sts)
412 int sts;
413 {
414 cleanup();
398 415
399 #ifdef USE_THREAD 416 #ifdef USE_THREAD
400 417
401 /* Other threads may still be active, so skip most of the 418 /* Other threads may still be active, so skip most of the
402 cleanup actions usually done (these are mostly for 419 cleanup actions usually done (these are mostly for
431 exit(sts); 448 exit(sts);
432 #endif /* USE_THREAD */ 449 #endif /* USE_THREAD */
433 /*NOTREACHED*/ 450 /*NOTREACHED*/
434 } 451 }
435 452
453 #ifdef HANDLE_SIGNALS
454 SIGTYPE
455 sighandler(sig)
456 int sig;
457 {
458 signal(sig, SIG_DFL); /* Don't catch recursive signals */
459 cleanup(); /* Do essential clean-up */
460 kill(getpid(), sig); /* Pretend the signal killed us */
461 /*NOTREACHED*/
462 }
463 #endif
464
465 void
466 initsigs()
467 {
468 initintr();
469 #ifdef HANDLE_SIGNALS
470 if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
471 signal(SIGHUP, sighandler);
472 if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
473 signal(SIGTERM, sighandler);
474 #endif
475 }
476
436 #ifdef TRACE_REFS 477 #ifdef TRACE_REFS
437 /* Ask a yes/no question */ 478 /* Ask a yes/no question */
438 479
439 int 480 int
440 askyesno(prompt) 481 askyesno(prompt)