<p><br>
On Feb 20, 2013 9:16 AM, "Mark Morgan Lloyd" <<a href="mailto:markMLl.lazarus@telemetry.co.uk">markMLl.lazarus@telemetry.co.uk</a>> wrote:<br>
><br>
> Mark Morgan Lloyd wrote:<br>
>>><br>
>>> If I want to poll a variable set by an asynchronous unix-style signal, i.e. that doesn't have an OS-level handle and where the latency should probably be of the order of 100mSec, what's the most effective technique?<br>
><br>
><br>
> > If I understand correctly, the self pipe trick is probably best, then<br>
> > you don't have to poll, just add the handle to select().<br>
><br>
> But there's no handle, simply a (global) variable. This continues from an earlier discussion where Sven was cautioning that about the only thing you could do safely in a signal handler was set a (global) variable: that bit I knew, but I don't know how best to deal with the variable once set if there's no convenient timer etc. (I should have threaded the question onto that, but I thought it was on a different list).</p>
<p>You create the pipe, add the read end fd to select, write a byte to the write end fd in the signal handler. There are a bunch of examples floating around on the web.</p>
<p>Henry</p>