Improved signal handling on Linux/BSD.
This commit is contained in:
parent
aeb7d1af4a
commit
64fa094b9f
@ -157,7 +157,6 @@ static void sigint_handler(const int sig)
|
||||
if (sig == SIGINT)
|
||||
{
|
||||
g_slunkcrypt_abort_flag = 1;
|
||||
signal(SIGINT, sigint_handler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,7 +556,7 @@ static int run_self_test(void)
|
||||
int MAIN(const int argc, CHR *const argv[])
|
||||
{
|
||||
init_terminal();
|
||||
signal(SIGINT, sigint_handler);
|
||||
setup_signal_handler(SIGINT, sigint_handler);
|
||||
int result = -1;
|
||||
|
||||
FPRINTF(stderr, T("SlunkCrypt Utility (%") T(PRIstr) T("-%") T(PRIstr) T("), by LoRd_MuldeR <MuldeR2@GMX.de>\n"), OS_TYPE, CPU_ARCH);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "utils.h"
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
@ -48,6 +49,19 @@ void init_terminal(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void setup_signal_handler(const int signo, signal_handler_t* const handler)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
signal(signo, handler);
|
||||
#else
|
||||
struct sigaction act;
|
||||
act.sa_handler = handler;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
sigaction(signo, &act, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
char* CHR_to_utf8(const CHR*const input)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -9,7 +9,10 @@
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef void (signal_handler_t)(int);
|
||||
|
||||
void init_terminal(void);
|
||||
void setup_signal_handler(const int signo, signal_handler_t* const handler);
|
||||
char* CHR_to_utf8(const CHR *const input);
|
||||
uint64_t get_file_size(FILE* const file);
|
||||
const CHR *get_file_name(const CHR *path);
|
||||
|
Loading…
Reference in New Issue
Block a user