0

I have implemented signal handling in C on windows visual studio spefically for SIGBREAK and SIGSEVG

but when i gave the added the code which could cause segmentation fault, my signal handler function dosent get call

but if used raise(SIGSEVG), signal handler does get called

this is how I am initializing signal signal(SIGBREAK, signal_handler) signal(SIGSEVG, signal_handler)

upon further checking I got to know that every time my signal() function is returning NULL the issue is same on linux platform also(CentOS 7)

so what should I do to fix this

Steve
  • 1
  • 2
  • Windows: does not implement asynchronous signals. Linux: [avoid signal, use sigaction instead](https://man7.org/linux/man-pages/man2/signal.2.html) – teapot418 Apr 28 '23 at 06:36
  • You seem to have multiple questions in one, probably try focusing a bit. I don't think you can handle a bad memory access in windows, the other one would deserve a closer look. And your code probably has a different problem on Linux. And this is unlikely to produce portable code, you may have to `#ifdef` a bit. – teapot418 Apr 28 '23 at 06:43
  • I tried this, but my signal.h dosen't have implementation of sigaction.. – Steve Apr 28 '23 at 06:43
  • It does on Linux unless you're compiling in a strict "standard C features only" mode. – Shawn Apr 28 '23 at 06:44
  • @teapot418 sir if possible can you please share any official documentation which states "you can't handle a bad memory access in windows, " – Steve Apr 28 '23 at 06:45
  • At least not in a portable way. This answer points to structured exceptions, I have no experience with those: https://stackoverflow.com/a/32531038/21105992 – teapot418 Apr 28 '23 at 06:49

0 Answers0