Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ts2phc: check is_running in ts2phc_pps_sink_poll()
A recent bug in the ts2phc_pps_sink_poll() function caused the ts2phc program to fail to exit in response to the SIGINT, SIGQUIT, SIGTERM, and SIGHUP signals. In normal behavior, these signals are caught by the handle_int_quit_term() function, which sets the global running variable to 0. This causes the main loop of the ts2phc main function to terminate and the program will clean up and then quit. However, if the ts2phc_pps_sink_poll() function does not exit -- as in the buggy situation previously mentioned -- then the ts2phc application will not exit. Additional error checking was added to ts2phc_pps_sink_poll() to prevent it from continuing when a clock device fails to poll. However, the application may still take some time to finish polling while waiting for events on all of the sink clocks. If the user has issued a signal, there is no reason to continue polling, and the application ought to stop immediately. In practice, if the signal arrives while the poll() system call is running, it will exit and set errno to EINTR. This normally causes the function to exit with a return of 0. However, if the signal arrives at another point, the function will continue polling until its normal exit condition. This could take some time, preventing the program from exiting quickly. Add a check against is_running() to the loop body, so that the ts2phc program will exit efficiently upon being signaled. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
- Loading branch information