diff options
author | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-04-16 15:17:02 +0000 |
---|---|---|
committer | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-04-16 15:17:02 +0000 |
commit | 1d9d8b551dba064006f730dbe29a28124dd58418 (patch) | |
tree | e8ceb6f445d8a868d75d7681188e164ec80057cc /linux-user | |
parent | aaf4ad391333d78c73900befb9971ff26d4938d4 (diff) |
Translate signal values in exit status.
Signed-off-by: Paul Brook <paul@codesourcery.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7131 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/qemu.h | 1 | ||||
-rw-r--r-- | linux-user/signal.c | 2 | ||||
-rw-r--r-- | linux-user/syscall.c | 17 |
3 files changed, 18 insertions, 2 deletions
diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 94ae3338e8..447caf9682 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -201,6 +201,7 @@ int queue_signal(CPUState *env, int sig, target_siginfo_t *info); 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); diff --git a/linux-user/signal.c b/linux-user/signal.c index 75047251bb..4abc5fa180 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -102,7 +102,7 @@ static inline int sas_ss_flags(unsigned long sp) : 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; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f5875aa1f7..ec04170b98 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3643,6 +3643,20 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, } #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 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, 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 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, 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; } |