Function rc_enable_signal_handler#

Function Documentation#

int rc_enable_signal_handler(void)#

Enables a generic signal handler. Optional but recommended.

This catches SIGINT, SIGTERM, SIGHUP, and SIGSEGV and does the following:

  • SIGINT (ctrl-c) Sets process state to EXITING indicating to the user threads to shut down cleanly. All user threads should check rc_get_state to catch this.

  • SITERM: Same as SIGINT above

  • SIGHUP: Ignored to prevent process from stopping due to loose USB network connection. Also allows robot control programs to keep running after USB cable in intentionally removed.

  • SIGSEGV: Segfaults will be caught and print some debugging info to the screen before setting rc_state to EXITING. Behavior with segfaults is no guaranteed to be predictable.

Returns:

Returns 0 on success or -1 on error