Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-02

Signal handling

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

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?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Anton Kavalenka
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote
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?

Thread1

fEvent.WaitFor(INFINITE); // hang on signal handle

Thread2

fEvent.SetEvent; // this releases thread1 form waiting

regards
Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130220/efd01117/attachment.html>

Reply by email

Henry Vermaak
to Mark Morgan Lloyd: If I want to poll a variable set by an asynchronous unix-style signal, i.e. that doesn't…

On Feb 20, 2013 8:36 AM, "Mark Morgan Lloyd" <

wrote: 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?

If I understand correctly, the self pipe trick is probably best, then you don't have to poll, just add the handle to select().

Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130220/1cfff48b/attachment-0001.html>

Reply by email

Mark Morgan Lloyd
to Mark Morgan Lloyd: If I want to poll a variable set by an asynchronous unix-style signal, i.e. that doesn't…
Mark Morgan Lloyd wrote 6 lines
> 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? If I understand correctly, the self pipe trick is probably best, then you don't have to poll, just add the handle to select().

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).

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Henry Vermaak
to Mark Morgan Lloyd

On Feb 20, 2013 9:16 AM, "Mark Morgan Lloyd" <

Show quoted text 5 lines
wrote: Mark Morgan Lloyd wrote: >> >> 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?

Show quoted text 6 lines
> If I understand correctly, the self pipe trick is probably best, then > you don't have to poll, just add the handle to select(). 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).

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.

Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130220/a41c6188/attachment.html>

Reply by email