diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-09-25 11:59:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-25 11:59:46 +0200 |
commit | b0deb55814fe7536ea1d2880a38839e0052dec24 (patch) | |
tree | e7d88911c2ed8695e879f1855f9743ac635364d9 /lib | |
parent | 548fc778c9b7048f474bf53c5d665bb8425e3343 (diff) | |
parent | 621ef184789bade93f9c2a44aef75885b8e73863 (diff) | |
download | Nim-b0deb55814fe7536ea1d2880a38839e0052dec24.tar.gz |
Merge pull request #9059 from Vindaar/onSignalMod
fix `posix.onSignal` example, inject current signal as `s`
Diffstat (limited to 'lib')
-rw-r--r-- | lib/posix/posix.nim | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index c230e6598..fa589e905 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -985,14 +985,21 @@ proc utimes*(path: cstring, times: ptr array[2, Timeval]): int {. proc handle_signal(sig: cint, handler: proc (a: cint) {.noconv.}) {.importc: "signal", header: "<signal.h>".} template onSignal*(signals: varargs[cint], body: untyped) = - ## Setup code to be executed when Unix signals are received. Example: - ## from posix import SIGINT, SIGTERM - ## onSignal(SIGINT, SIGTERM): - ## echo "bye" + ## Setup code to be executed when Unix signals are received. The + ## currently handled signal is injected as ``sig`` into the calling + ## scope. + ## + ## Example: + ## + ## .. code-block:: + ## from posix import SIGINT, SIGTERM + ## onSignal(SIGINT, SIGTERM): + ## echo "bye from signal ", sig for s in signals: handle_signal(s, - proc (sig: cint) {.noconv.} = + proc (signal: cint) {.noconv.} = + let sig {.inject.} = signal body ) |