summary refs log tree commit diff stats
path: root/lib/posix
diff options
context:
space:
mode:
authorSebastian Schmidt <basti90@gmail.com>2018-09-24 23:49:13 +0200
committerSebastian Schmidt <basti90@gmail.com>2018-09-24 23:49:13 +0200
commit621ef184789bade93f9c2a44aef75885b8e73863 (patch)
tree7e3674285dfe26514ce5aeabd5a357d7fa6e1b1a /lib/posix
parent4c6382a334feeeef601aeed4dd8ff8cb672d1678 (diff)
downloadNim-621ef184789bade93f9c2a44aef75885b8e73863.tar.gz
inject `sig` from anonymous proc instead of for loop
Diffstat (limited to 'lib/posix')
-rw-r--r--lib/posix/posix.nim9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index b63a00e11..fa589e905 100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -986,7 +986,7 @@ proc handle_signal(sig: cint, handler: proc (a: cint) {.noconv.}) {.importc: "si
 
 template onSignal*(signals: varargs[cint], body: untyped) =
   ## Setup code to be executed when Unix signals are received. The
-  ## currently handled signal is injected as ``s`` into the calling
+  ## currently handled signal is injected as ``sig`` into the calling
   ## scope.
   ##
   ## Example:
@@ -994,11 +994,12 @@ template onSignal*(signals: varargs[cint], body: untyped) =
   ## .. code-block::
   ##   from posix import SIGINT, SIGTERM
   ##   onSignal(SIGINT, SIGTERM):
-  ##     echo "bye from signal ", s
+  ##     echo "bye from signal ", sig
 
-  for s {.inject.} in signals:
+  for s in signals:
     handle_signal(s,
-      proc (sig: cint) {.noconv.} =
+      proc (signal: cint) {.noconv.} =
+        let sig {.inject.} = signal
         body
     )