Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuTKu-0002cO-7i for qemu-devel@nongnu.org; Thu, 16 Apr 2009 11:17:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuTKs-0002c8-Os for qemu-devel@nongnu.org; Thu, 16 Apr 2009 11:17:07 -0400 Received: from [199.232.76.173] (port=33569 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuTKs-0002c5-Jf for qemu-devel@nongnu.org; Thu, 16 Apr 2009 11:17:06 -0400 Received: from savannah.gnu.org ([199.232.41.3]:40930 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LuTKr-00042c-HU for qemu-devel@nongnu.org; Thu, 16 Apr 2009 11:17:06 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LuTKq-0007Pq-1K for qemu-devel@nongnu.org; Thu, 16 Apr 2009 15:17:04 +0000 Received: from pbrook by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LuTKp-0007Pm-CE for qemu-devel@nongnu.org; Thu, 16 Apr 2009 15:17:03 +0000 MIME-Version: 1.0 Errors-To: pbrook Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Paul Brook Message-Id: Date: Thu, 16 Apr 2009 15:17:03 +0000 Subject: [Qemu-devel] [7131] Translate signal values in exit status. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 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; }