diff options
author | Jo-Philipp Wich <jo@mein.io> | 2023-07-11 13:30:51 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2023-07-27 13:59:32 +0200 |
commit | 29b1c0deba8487d1d7ad86242a1a5e90aa775218 (patch) | |
tree | 984a28dea6f2fd88a112f7d49709c32c0a8fa858 /lib.c | |
parent | bb5eba4db8895d862038825b84d5b7a94ee5cbb0 (diff) |
vm: introduce basic signal handling infrastructure
Introduce the basic facilities to implement UNIX process signal handling
in ucode. The VM structure is extended by a bitmap keeping track of
received signal numbers, a sigaction structure which holds a generic
signal handler to update the bitmap, a pipe where the generic signal
handler will send received signal numbers to and an array of managed
signal handler functions, indexed by signal number.
Additionally, three new C API functions are added to control signal
delivery in the VM instance:
- `uc_vm_signal_dispatch()`
This function invokes signal handler callbacks for each received
signal number, clears the bitmap and empties the pipe. The VM itself
will invoke this function after each executed bytecode instruction.
In some cases however it is useful for C code driving the VM to
force immediate signal delivery, e.g. from within long running C
functions that do not return to ucode (to the next bytecode
instruction) in a timely manner.
- `uc_vm_signal_raise()`
This function will deliver the given signal number, so that it is
picked up by the next call to `uc_vm_signal_dispatch()`. It is used
by the generic C signal handler function to forward received signals
to the VM instance.
- `uc_vm_signal_notifyfd()`
This functions returns the read end of the internal signal pipe.
It is mainly useful for integration into select or poll based event
loops, in order to be notified when there's pending signals for
delivery into the VM instance.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib.c')
0 files changed, 0 insertions, 0 deletions