diff options
author | Jo-Philipp Wich <jo@mein.io> | 2023-08-07 01:01:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-07 01:01:02 +0200 |
commit | a38315454add264a41094524e1fcf435acb85fe8 (patch) | |
tree | fb6cf7d52f641e35316b4db39a1a424927d77ba5 /include | |
parent | bb5eba4db8895d862038825b84d5b7a94ee5cbb0 (diff) | |
parent | 2593270498be82de82f770cb3744d9e5f8d0b0bd (diff) |
Merge pull request #157 from jow-/signal-handling
Introduce signal handling
Diffstat (limited to 'include')
-rw-r--r-- | include/ucode/types.h | 8 | ||||
-rw-r--r-- | include/ucode/vm.h | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/ucode/types.h b/include/ucode/types.h index 9827db5..641c469 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -20,6 +20,7 @@ #include <stdbool.h> #include <stdint.h> #include <regex.h> +#include <signal.h> #include <json-c/json.h> #include "util.h" @@ -230,6 +231,7 @@ typedef struct { bool raw_mode; uc_search_path_t module_search_path; uc_search_path_t force_dynlink_list; + bool setup_signal_handlers; } uc_parse_config_t; extern uc_parse_config_t uc_default_parse_config; @@ -311,6 +313,12 @@ struct uc_vm { uc_stringbuf_t *strbuf; uc_exception_handler_t *exhandler; FILE *output; + struct { + uint64_t raised[((NSIG + 63) & ~63) / 64]; + uc_value_t *handler; + struct sigaction sa; + int sigpipe[2]; + } signal; }; diff --git a/include/ucode/vm.h b/include/ucode/vm.h index 161f1ee..3cb6dc0 100644 --- a/include/ucode/vm.h +++ b/include/ucode/vm.h @@ -156,4 +156,8 @@ uc_vm_raise_exception(uc_vm_t *vm, uc_exception_type_t type, const char *fmt, .. uc_vm_status_t uc_vm_execute(uc_vm_t *vm, uc_program_t *fn, uc_value_t **retval); uc_value_t *uc_vm_invoke(uc_vm_t *vm, const char *fname, size_t nargs, ...); +uc_exception_type_t uc_vm_signal_dispatch(uc_vm_t *vm); +void uc_vm_signal_raise(uc_vm_t *vm, int signo); +int uc_vm_signal_notifyfd(uc_vm_t *vm); + #endif /* UCODE_VM_H */ |