@encthenet write(2) to a self pipe you already have open is also safe and well-trodden, in order to inject an event into your event loop. Some OSes also have event loop systems with a facility built for this, such as port_send(3C) from event ports on illumos.