Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib Translate signal numbers between rump kernel and (POSIX)...



details:   https://anonhg.NetBSD.org/src/rev/2d2f1caf8997
branches:  trunk
changeset: 326833:2d2f1caf8997
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Feb 20 00:42:27 2014 +0000

description:
Translate signal numbers between rump kernel and (POSIX) host.

diffstat:

 lib/librumpclient/rumpclient.c      |   11 ++-
 lib/librumpuser/Makefile            |    6 +-
 lib/librumpuser/rumpuser.c          |   15 +--
 lib/librumpuser/rumpuser_sigtrans.c |  126 ++++++++++++++++++++++++++++++++++++
 4 files changed, 142 insertions(+), 16 deletions(-)

diffs (242 lines):

diff -r 4665644670d2 -r 2d2f1caf8997 lib/librumpclient/rumpclient.c
--- a/lib/librumpclient/rumpclient.c    Thu Feb 20 00:41:05 2014 +0000
+++ b/lib/librumpclient/rumpclient.c    Thu Feb 20 00:42:27 2014 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rumpclient.c,v 1.55 2013/09/10 16:53:06 pooka Exp $   */
+/*      $NetBSD: rumpclient.c,v 1.56 2014/02/20 00:42:27 pooka Exp $   */
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -48,7 +48,7 @@
 #define USE_KQUEUE
 #endif
 
-__RCSID("$NetBSD: rumpclient.c,v 1.55 2013/09/10 16:53:06 pooka Exp $");
+__RCSID("$NetBSD: rumpclient.c,v 1.56 2014/02/20 00:42:27 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/mman.h>
@@ -99,6 +99,7 @@
 int    (*host_execve)(const char *, char *const[], char *const[]);
 
 #include "sp_common.c"
+#include "rumpuser_sigtrans.c"
 
 static struct spclient clispc = {
        .spc_fd = -1,
@@ -590,6 +591,7 @@
        void *mapaddr;
        size_t maplen;
        int reqtype = spc->spc_hdr.rsp_type;
+       int sig;
 
        switch (reqtype) {
        case RUMPSP_COPYIN:
@@ -623,8 +625,9 @@
                send_anonmmap_resp(spc, spc->spc_hdr.rsp_reqno, mapaddr);
                break;
        case RUMPSP_RAISE:
-               DPRINTF(("rump_sp handlereq: raise sig %d\n", rhdr->rsp_signo));
-               raise((int)rhdr->rsp_signo);
+               sig = rumpuser__sig_rump2host(rhdr->rsp_signo);
+               DPRINTF(("rump_sp handlereq: raise sig %d\n", sig));
+               raise(sig);
                /*
                 * We most likely have signals blocked, but the signal
                 * will be handled soon enough when we return.
diff -r 4665644670d2 -r 2d2f1caf8997 lib/librumpuser/Makefile
--- a/lib/librumpuser/Makefile  Thu Feb 20 00:41:05 2014 +0000
+++ b/lib/librumpuser/Makefile  Thu Feb 20 00:42:27 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.15 2013/09/10 16:51:24 pooka Exp $
+#      $NetBSD: Makefile,v 1.16 2014/02/20 00:42:27 pooka Exp $
 #
 
 .include <bsd.own.mk>
@@ -19,7 +19,9 @@
 
 SRCS=          rumpuser.c
 SRCS+=         rumpuser_pth.c
-SRCS+=         rumpuser_component.c rumpuser_errtrans.c rumpuser_bio.c
+SRCS+=         rumpuser_component.c rumpuser_bio.c
+
+SRCS+=         rumpuser_errtrans.c rumpuser_sigtrans.c
 
 # optional
 SRCS+=         rumpuser_dl.c rumpuser_sp.c rumpuser_daemonize.c
diff -r 4665644670d2 -r 2d2f1caf8997 lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c        Thu Feb 20 00:41:05 2014 +0000
+++ b/lib/librumpuser/rumpuser.c        Thu Feb 20 00:42:27 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser.c,v 1.55 2013/10/27 16:39:46 rmind Exp $      */
+/*     $NetBSD: rumpuser.c,v 1.56 2014/02/20 00:42:27 pooka Exp $      */
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.55 2013/10/27 16:39:46 rmind Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.56 2014/02/20 00:42:27 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/ioctl.h>
@@ -643,13 +643,12 @@
 }
 
 int
-rumpuser_kill(int64_t pid, int sig)
+rumpuser_kill(int64_t pid, int rumpsig)
 {
-       int rv;
-
-#ifdef __NetBSD__
+       int rv, sig;
        int error;
 
+       sig = rumpuser__sig_rump2host(rumpsig);
        if (pid == RUMPUSER_PID_SELF) {
                error = raise(sig);
        } else {
@@ -659,10 +658,6 @@
                rv = errno;
        else
                rv = 0;
-#else
-       /* XXXfixme: signal numbers may not match on non-NetBSD */
-       rv = EOPNOTSUPP;
-#endif
 
        ET(rv);
 }
diff -r 4665644670d2 -r 2d2f1caf8997 lib/librumpuser/rumpuser_sigtrans.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/librumpuser/rumpuser_sigtrans.c       Thu Feb 20 00:42:27 2014 +0000
@@ -0,0 +1,126 @@
+/*     $NetBSD: rumpuser_sigtrans.c,v 1.1 2014/02/20 00:42:27 pooka Exp $      */
+
+/*
+ * pseudo-automatically generated.  PLEASE DO EDIT (e.g. in case there
+ * are errnos which are defined to be the same value)
+ *
+ * The body of the switch statement was generated using:
+ *
+ * awk '/^#define/ && $2 ~ "^SIG[A-Z]" \
+ *   {printf "#ifdef %s\n\tcase %d\t: return %s;\n#endif\n", $2, $3, $2}' \
+ *   signal.h
+ */
+
+#include <signal.h>
+
+/*
+ * Translate rump kernel signal number to host signal number
+ */
+int rumpuser__sig_rump2host(int); /* a naughty decouple */
+int
+rumpuser__sig_rump2host(int rumpsig)
+{
+
+       switch(rumpsig) {
+       case 0  : return 0;
+#ifdef SIGHUP
+       case 1  : return SIGHUP;
+#endif
+#ifdef SIGINT
+       case 2  : return SIGINT;
+#endif
+#ifdef SIGQUIT
+       case 3  : return SIGQUIT;
+#endif
+#ifdef SIGILL
+       case 4  : return SIGILL;
+#endif
+#ifdef SIGTRAP
+       case 5  : return SIGTRAP;
+#endif
+#ifdef SIGABRT
+       case 6  : return SIGABRT;
+#endif
+#ifdef SIGEMT
+       case 7  : return SIGEMT;
+#endif
+#ifdef SIGFPE
+       case 8  : return SIGFPE;
+#endif
+#ifdef SIGKILL
+       case 9  : return SIGKILL;
+#endif
+#ifdef SIGBUS
+       case 10 : return SIGBUS;
+#endif
+#ifdef SIGSEGV
+       case 11 : return SIGSEGV;
+#endif
+#ifdef SIGSYS
+       case 12 : return SIGSYS;
+#endif
+#ifdef SIGPIPE
+       case 13 : return SIGPIPE;
+#endif
+#ifdef SIGALRM
+       case 14 : return SIGALRM;
+#endif
+#ifdef SIGTERM
+       case 15 : return SIGTERM;
+#endif
+#ifdef SIGURG
+       case 16 : return SIGURG;
+#endif
+#ifdef SIGSTOP
+       case 17 : return SIGSTOP;
+#endif
+#ifdef SIGTSTP
+       case 18 : return SIGTSTP;
+#endif
+#ifdef SIGCONT
+       case 19 : return SIGCONT;
+#endif
+#ifdef SIGCHLD
+       case 20 : return SIGCHLD;
+#elif defined(SIGCLD)
+       case 20 : return SIGCLD;
+#endif
+#ifdef SIGTTIN
+       case 21 : return SIGTTIN;
+#endif
+#ifdef SIGTTOU
+       case 22 : return SIGTTOU;
+#endif
+#ifdef SIGIO
+       case 23 : return SIGIO;
+#endif
+#ifdef SIGXCPU
+       case 24 : return SIGXCPU;
+#endif
+#ifdef SIGXFSZ
+       case 25 : return SIGXFSZ;
+#endif
+#ifdef SIGVTALRM
+       case 26 : return SIGVTALRM;
+#endif
+#ifdef SIGPROF
+       case 27 : return SIGPROF;
+#endif
+#ifdef SIGWINCH
+       case 28 : return SIGWINCH;
+#endif
+#ifdef SIGINFO
+       case 29 : return SIGINFO;
+#endif
+#ifdef SIGUSR1
+       case 30 : return SIGUSR1;
+#endif
+#ifdef SIGUSR2
+       case 31 : return SIGUSR2;
+#endif
+#ifdef SIGPWR
+       case 32 : return SIGPWR;
+#endif
+       default:        return -1;
+       }
+}



Home | Main Index | Thread Index | Old Index