Skip to content

Commit 8ec68a0

Browse files
vivierstsquad
authored andcommitted
linux-user: fix clock_nanosleep()
If the call is interrupted by a signal handler, it fails with error EINTR and if "remain" is not NULL and "flags" is not TIMER_ABSTIME, it returns the remaining unslept time in "remain". Update linux-user to not overwrite the "remain" structure if there is no error. Found with "make check-tcg", linux-test fails on nanosleep test: TEST linux-test on x86_64 .../tests/tcg/multiarch/linux-test.c:242: nanosleep Reported-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Laurent Vivier <[email protected]> Signed-off-by: Alex Bennée <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]> Message-Id: <[email protected]>
1 parent 4c5aeb1 commit 8ec68a0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

linux-user/syscall.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11831,8 +11831,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
1183111831
target_to_host_timespec(&ts, arg3);
1183211832
ret = get_errno(safe_clock_nanosleep(arg1, arg2,
1183311833
&ts, arg4 ? &ts : NULL));
11834-
if (arg4)
11834+
/*
11835+
* if the call is interrupted by a signal handler, it fails
11836+
* with error -TARGET_EINTR and if arg4 is not NULL and arg2 is not
11837+
* TIMER_ABSTIME, it returns the remaining unslept time in arg4.
11838+
*/
11839+
if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME) {
1183511840
host_to_target_timespec(arg4, &ts);
11841+
}
1183611842

1183711843
#if defined(TARGET_PPC)
1183811844
/* clock_nanosleep is odd in that it returns positive errno values.

0 commit comments

Comments
 (0)