diff options
author | Vindaar <basti90@gmail.com> | 2018-09-24 11:21:45 +0200 |
---|---|---|
committer | Vindaar <basti90@gmail.com> | 2018-09-24 11:21:45 +0200 |
commit | 4c6382a334feeeef601aeed4dd8ff8cb672d1678 (patch) | |
tree | d5dfcf8746905fa5ea5e92850fc0dc317a9063e4 /lib/posix | |
parent | fedd695d76e621bfbbaca4bbc8f66996a0a732a4 (diff) | |
download | Nim-4c6382a334feeeef601aeed4dd8ff8cb672d1678.tar.gz |
fix `posix.onSignal` example, inject current signal as `s`
Diffstat (limited to 'lib/posix')
-rw-r--r-- | lib/posix/posix.nim | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index c230e6598..b63a00e11 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -985,12 +985,18 @@ 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 ``s`` into the calling + ## scope. + ## + ## Example: + ## + ## .. code-block:: + ## from posix import SIGINT, SIGTERM + ## onSignal(SIGINT, SIGTERM): + ## echo "bye from signal ", s - for s in signals: + for s {.inject.} in signals: handle_signal(s, proc (sig: cint) {.noconv.} = body |