diff options
| author | J08nY | 2017-10-04 14:48:31 +0200 |
|---|---|---|
| committer | J08nY | 2017-10-04 14:48:31 +0200 |
| commit | 45c08cad912299a8d2043e432bb38e003151526b (patch) | |
| tree | f2b41144dd4f97cee73feb1b36b0cbd1a6725d4f /src/util/timeout.c | |
| parent | 42576337198e76fa0f5dad74800237254a0fda35 (diff) | |
| download | ecgen-45c08cad912299a8d2043e432bb38e003151526b.tar.gz ecgen-45c08cad912299a8d2043e432bb38e003151526b.tar.zst ecgen-45c08cad912299a8d2043e432bb38e003151526b.zip | |
Diffstat (limited to 'src/util/timeout.c')
| -rw-r--r-- | src/util/timeout.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util/timeout.c b/src/util/timeout.c new file mode 100644 index 0000000..51138fd --- /dev/null +++ b/src/util/timeout.c @@ -0,0 +1,21 @@ +/* + * ecgen, tool for generating Elliptic curve domain parameters + * Copyright (C) 2017 J08nY + */ +#include "timeout.h" +#include <signal.h> + +__thread jmp_buf exception; + +void timeout_handle(int signum) { longjmp(exception, 1); } + +bool timeout_init(const config_t *cfg) { + struct sigaction new_action; + + new_action.sa_handler = timeout_handle; + sigemptyset(&new_action.sa_mask); + new_action.sa_flags = 0; + + sigaction(SIGALRM, &new_action, NULL); + return true; +}
\ No newline at end of file |
