Reputation: 101
I try to catch a signal, but struct sigaction
is not defined in <signal.h>.
Previously, this worked on Ubuntu with gcc compiler.
Some piece of code:
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#define _POSIX_C_SOURCE 199309L
#include <signal.h>
//#include <stdlib.h>
HANDLE hCom;
HANDLE hEvent;
void diediedie(int sig) {
puts("Bye, brutal world!");
if (hEvent)
CloseHandle(hEvent);
if (hCom)
CloseHandle(hCom);
exit(1);
}
int catch_signal(int sig, void (*handler)(int)) {
struct sigaction action; // <- this struct
action.sa_handler = handler;
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
return sigaction(sig, &action, NULL);
}
...some code here...
I read this topic How do I use sigaction()? struct sigaction is not defined , and defined _POSIX_C_SOURCE
, but it didn't help.
I can't understand what should I do and why the code doesn't work.
Could someone explain please for a newbie?
Upvotes: 0
Views: 984
Reputation: 101
Sorry, I found that in Windows I should use just void __cdecl *signal(int sig, int (*func)(int, int));
Upvotes: 1