Skip to content

Commit

Permalink
vm: close signal pipe in uc_vm_signal_handlers_reset()
Browse files Browse the repository at this point in the history
The previously introduced signal handler restoration logic did not take
the signal dispatching pipe into account.

Extend the `uc_vm_signal_handlers_reset()` function to also close any
related pipe handles.

Fixes: #255
Fixes: f9d2faf ("vm: reset signals when freeing VM")
Signed-off-by: Jo-Philipp Wich <[email protected]>
  • Loading branch information
jow- committed Dec 11, 2024
1 parent 3eb4e2a commit 0b80ceb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ uc_vm_signal_handlers_reset(uc_vm_t *vm)
{
uc_thread_context_t *tctx = uc_thread_context_get();
struct sigaction sa = { 0 };
size_t signo;
size_t i, signo;

if (vm != tctx->signal_handler_vm)
return;
Expand All @@ -202,6 +202,13 @@ uc_vm_signal_handlers_reset(uc_vm_t *vm)
if (ucv_is_callable(ucv_array_get(vm->signal.handler, signo)))
sigaction(signo, &sa, NULL);

for (i = 0; i < ARRAY_SIZE(vm->signal.sigpipe); i++) {
if (vm->signal.sigpipe[i] > STDERR_FILENO)
close(vm->signal.sigpipe[i]);

vm->signal.sigpipe[i] = -1;
}

tctx->signal_handler_vm = NULL;
}

Expand Down

0 comments on commit 0b80ceb

Please sign in to comment.