From d394a6efed4723b86f8e4f09fc23f6d03a7ad835 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 20 Jun 2021 23:06:10 -0400 Subject: sim: callback: add a kill interface This will make it easier to emulate the syscall. If the kill target is the sim itself, don't do anything. This forces the higher layers to make a decision as to how to handle this event: like halting the overall engine process. --- sim/common/syscall.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'sim/common/syscall.c') diff --git a/sim/common/syscall.c b/sim/common/syscall.c index 7ef34b9..6efddcf 100644 --- a/sim/common/syscall.c +++ b/sim/common/syscall.c @@ -583,6 +583,24 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc) result = (*cb->getpid) (cb); break; + case CB_SYS_kill: + /* If killing self, leave it to the caller to process so it can send the + signal to the engine. */ + if (sc->arg1 == (*cb->getpid) (cb)) + { + result = -1; + errcode = ENOSYS; + } + else + { + int signum = cb_target_to_host_signal (cb, sc->arg2); + + result = (*cb->kill) (cb, sc->arg1, signum); + cb->last_errno = errno; + goto ErrorFinish; + } + break; + case CB_SYS_time : { /* FIXME: May wish to change CB_SYS_time to something else. -- cgit v1.1