sim: callback: add a kill interface
[binutils-gdb.git] / sim / common / syscall.c
index 4e76d2008a30d3287a6594b51fdfdadbde0c7015..6efddcfecde80abc0da203b153e8090e71f06713 100644 (file)
@@ -579,7 +579,26 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc)
       break;
 
     case CB_SYS_getpid:
-      result = getpid ();
+      /* POSIX says getpid always succeeds.  */
+      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 :