tenox7 / ttyplot

a realtime plotting utility for terminal/console with data input from stdin
Apache License 2.0
956 stars 42 forks source link

Catch signals using a self-pipe (follow-up to #98 and #132) #143

Closed edgar-bonet closed 7 months ago

edgar-bonet commented 7 months ago

As noticed by @hartwork, pselect is not a reliable way of catching signals on Linux: in case of high input pressure, signal delivery is starved. Pull request #132 partially fixed the issue by issuing two consecutive pselect calls, but this left a race window between these two calls.

This pull request fixes the issue without race conditions by using plain select() and a self-pipe, which makes signal delivery reliable.

This is one of two possible alternatives, the other one being signalfd (#142).