I have a Xlib-based program with an event loop that uses XNextEvent
to receive and process relevant events.
I would like to be able to gracefully close this program from another process (actually from a shell script). I need to do some cleanup when closing, so I considered to setup a signal handler (for example for SIGUSR1) and when this signal is received, do the appropriate cleanup.
My question is, how can I interrupt the (blocking) XNextEvent
call from the signal handler?
Any other suggestions?