qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paul Brook <paul@nowt.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [7131] Translate signal values in exit status.
Date: Thu, 16 Apr 2009 15:17:03 +0000	[thread overview]
Message-ID: <E1LuTKp-0007Pm-CE@cvs.savannah.gnu.org> (raw)

Revision: 7131
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7131
Author:   pbrook
Date:     2009-04-16 15:17:02 +0000 (Thu, 16 Apr 2009)
Log Message:
-----------
Translate signal values in exit status.

Signed-off-by: Paul Brook <paul@codesourcery.com>

Modified Paths:
--------------
    trunk/linux-user/qemu.h
    trunk/linux-user/signal.c
    trunk/linux-user/syscall.c

Modified: trunk/linux-user/qemu.h
===================================================================
--- trunk/linux-user/qemu.h	2009-04-16 14:17:14 UTC (rev 7130)
+++ trunk/linux-user/qemu.h	2009-04-16 15:17:02 UTC (rev 7131)
@@ -201,6 +201,7 @@
 void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
 void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
 int target_to_host_signal(int sig);
+int host_to_target_signal(int sig);
 long do_sigreturn(CPUState *env);
 long do_rt_sigreturn(CPUState *env);
 abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);

Modified: trunk/linux-user/signal.c
===================================================================
--- trunk/linux-user/signal.c	2009-04-16 14:17:14 UTC (rev 7130)
+++ trunk/linux-user/signal.c	2009-04-16 15:17:02 UTC (rev 7131)
@@ -102,7 +102,7 @@
             : on_sig_stack(sp) ? SS_ONSTACK : 0);
 }
 
-static inline int host_to_target_signal(int sig)
+int host_to_target_signal(int sig)
 {
     if (sig > 64)
         return sig;

Modified: trunk/linux-user/syscall.c
===================================================================
--- trunk/linux-user/syscall.c	2009-04-16 14:17:14 UTC (rev 7130)
+++ trunk/linux-user/syscall.c	2009-04-16 15:17:02 UTC (rev 7131)
@@ -3643,6 +3643,20 @@
 }
 #endif
 
+/* Map host to target signal numbers for the wait family of syscalls.
+   Assume all other status bits are the same.  */
+static int host_to_target_waitstatus(int status)
+{
+    if (WIFSIGNALED(status)) {
+        return host_to_target_signal(WTERMSIG(status)) | (status & ~0x7f);
+    }
+    if (WIFSTOPPED(status)) {
+        return (host_to_target_signal(WSTOPSIG(status)) << 8)
+               | (status & 0xff);
+    }
+    return status;
+}
+
 int get_osversion(void)
 {
     static int osversion;
@@ -3786,7 +3800,7 @@
             int status;
             ret = get_errno(waitpid(arg1, &status, arg3));
             if (!is_error(ret) && arg2
-                && put_user_s32(status, arg2))
+                && put_user_s32(host_to_target_waitstatus(status), arg2))
                 goto efault;
         }
         break;
@@ -5136,6 +5150,7 @@
             ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr));
             if (!is_error(ret)) {
                 if (status_ptr) {
+                    status = host_to_target_waitstatus(status);
                     if (put_user_s32(status, status_ptr))
                         goto efault;
                 }

                 reply	other threads:[~2009-04-16 15:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1LuTKp-0007Pm-CE@cvs.savannah.gnu.org \
    --to=paul@nowt.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).