Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

sysdep.c

Go to the documentation of this file.
00001 #include "soarkernel.h"
00002 
00003 /* ===================================================================
00004    
00005                         Signal Handling
00006 
00007    Setup things so control_c_handler() gets control whenever the program
00008    receives a SIGINT (e.g., from a ctrl-c at the keyboard).  The handler
00009    just sets the stop_soar flag.
00010 =================================================================== */
00011 
00012 char *c_interrupt_msg = "*** Ctrl-C Interrupt ***";
00013 
00014 /* AGR 581  The variable the_signal is not used at all, so I thought I
00015    would remove it.  Unfortunately, the signal command at the end of this
00016    function requires a function name that has a single integer parameter.
00017    It's probably some unix thing.  So I left the variable in the parameter
00018    list and instead changed the calling functions to use a parameter.
00019    94.11.15 (although this was done a month or two earlier--this comment
00020    was placed here in retrospect.)  */
00021 
00022 void control_c_handler(int the_signal)
00023 {
00024 
00025 /* Windows 3.1 can't do ^C handling */
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     /* --- reinstall this signal handler -- some brain-damaged OS's uninstall
00038        it after delivering the signal --- */
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                          /* _WINDOWS */
00055 
00056 }

Generated on Thu Dec 11 13:00:24 2003 for Soar Kernel by doxygen 1.3.5