-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
Description
Hello,
I see the SigAction struct of posix miss the field sa_sigaction*: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.} for amd64
Nim/lib/posix/posix_linux_amd64.nim
Lines 304 to 313 in 767a901
| Sigaction* {.importc: "struct sigaction", | |
| header: "<signal.h>", final, pure.} = object ## struct sigaction | |
| sa_handler*: proc (x: cint) {.noconv.} ## Pointer to a signal-catching | |
| ## function or one of the macros | |
| ## SIG_IGN or SIG_DFL. | |
| sa_mask*: Sigset ## Set of signals to be blocked during execution of | |
| ## the signal handling function. | |
| sa_flags*: cint ## Special flags. | |
| sa_restorer: proc() {.noconv.} ## not intended for application use. | |
However, I have tested in c, it seems we can define use this field succesfully on my amd64 machine
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <string.h>
#define SEGV_STACK_SIZE (MINSIGSTKSZ + 4096)
void sigsegv_handler(int signum, siginfo_t *info, void *data) {
void *addr = info->si_addr;
printf("Segmentation fault from reading the address %p\n", addr);
exit(1);
}
int main() {
stack_t segv_stack; // #Stack
segv_stack.ss_sp = posix_memalign(SEGV_STACK_SIZE); //#-> to import, included already in stdlib.h
segv_stack.ss_flags = 0;
segv_stack.ss_size = SEGV_STACK_SIZE;
sigaltstack(&segv_stack, NULL); // #sigaltstack
struct sigaction action; // #Sigaction
action.sa_flags = SA_SIGINFO | SA_ONSTACK;
action.sa_sigaction = &sigsegv_handler;
sigaction(SIGSEGV, &action, NULL); // #sigaction
printf("Installed signal handler for SIGSEGV.\n");
int* ptr = NULL;
*ptr = 42;
return 0;
}Nim Version
v2.0.4 Fedora, on amd64
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
No response