summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJacek Sieka <arnetheduck@gmail.com>2023-06-27 10:09:04 +0200
committerGitHub <noreply@github.com>2023-06-27 10:09:04 +0200
commit47635d30315595fc2dbe2162b691aff0f8e0f459 (patch)
tree7dd841b75c2859eb1baedbc65a0112b8dda1f099
parentcb40f11e6c0a8f8df8b429f239483c408c7cc668 (diff)
downloadNim-47635d30315595fc2dbe2162b691aff0f8e0f459.tar.gz
fix Sigaction struct definition (#22160)
SigInfo is still wrong (most of its fields are in a union)
-rw-r--r--lib/posix/posix_linux_amd64.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/posix/posix_linux_amd64.nim b/lib/posix/posix_linux_amd64.nim
index 91c290a44..a039d3808 100644
--- a/lib/posix/posix_linux_amd64.nim
+++ b/lib/posix/posix_linux_amd64.nim
@@ -310,7 +310,7 @@ type
     sa_mask*: Sigset ## Set of signals to be blocked during execution of
                       ## the signal handling function.
     sa_flags*: cint   ## Special flags.
-    sa_sigaction*: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}
+    sa_restorer: proc() {.noconv.}   ## not intended for application use.
 
   Stack* {.importc: "stack_t",
             header: "<signal.h>", final, pure.} = object ## stack_t
@@ -326,9 +326,9 @@ type
   SigInfo* {.importc: "siginfo_t",
               header: "<signal.h>", final, pure.} = object ## siginfo_t
     si_signo*: cint    ## Signal number.
-    si_code*: cint     ## Signal code.
     si_errno*: cint    ## If non-zero, an errno value associated with
                        ## this signal, as defined in <errno.h>.
+    si_code*: cint     ## Signal code.
     si_pid*: Pid       ## Sending process ID.
     si_uid*: Uid       ## Real user ID of sending process.
     si_addr*: pointer  ## Address of faulting instruction.
@@ -337,6 +337,12 @@ type
     si_value*: SigVal  ## Signal value.
     pad {.importc: "_pad".}: array[128 - 56, uint8]
 
+template sa_sigaction*(v: Sigaction): proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.} =
+  cast[proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}](v.sa_handler)
+proc `sa_sigaction=`*(v: var Sigaction, x: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}) =
+  v.sa_handler = cast[proc (x: cint) {.noconv.}](x)
+
+type
   Nl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint
   Nl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = pointer