00001 #include "soarkernel.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 char *c_interrupt_msg = "*** Ctrl-C Interrupt ***";
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 void control_c_handler(int the_signal)
00023 {
00024
00025
00026 #ifndef _WINDOWS
00027
00028 cons *c;
00029 agent *the_agent;
00030
00031 for (c = all_soar_agents; c != NIL; c = c->rest) {
00032 the_agent = ((agent *) c->first);
00033 the_agent->stop_soar = TRUE;
00034 the_agent->reason_for_stopping = c_interrupt_msg;
00035 }
00036
00037
00038
00039 signal(SIGINT, control_c_handler);
00040
00041 #endif
00042
00043 the_signal = the_signal;
00044 }
00045
00046 void setup_signal_handling(void)
00047 {
00048
00049 #ifndef _WINDOWS
00050 if (signal(SIGINT, control_c_handler) == SIG_ERR) {
00051 fprintf(stderr, "setup_signal_handling: unable to install signal handler.\n");
00052 fprintf(stderr, " Ctrl-C will not interrupt Soar.\n");
00053 }
00054 #endif
00055
00056 }