From 9458de9ac664cd75540c8b638b9a6caf82812fc8 Mon Sep 17 00:00:00 2001 From: zhushengle Date: Thu, 22 Jul 2021 19:56:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20nanosleep=20=E6=8E=A5=E5=8F=A3=E7=9A=84r?= =?UTF-8?q?mtp=E5=8F=82=E6=95=B0=E8=A2=AB=E9=94=99=E8=AF=AF=E6=B8=85?= =?UTF-8?q?=E9=9B=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit posix/linux 标准: nanosleep 使线程进入到了可被信号中断的状态,当线程睡眠被信号 中断,线程回复运行态时,若rmtp不为NULL,则会将sleep剩余的时间 记录在rmtp参数中返回,但是如果线程sleep过程中未被信号唤醒, 则忽略该参数。 由于鸿蒙中nanosleep是不可被打断的,即rmtp应该被忽略,而不是清零。 Close #I41U0R Signed-off-by: zhushengle Change-Id: I6622eb43d6782c2b53b99d9df5cfff5f5e1ed79c --- syscall/time_syscall.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/syscall/time_syscall.c b/syscall/time_syscall.c index e433e2de..ea87f298 100644 --- a/syscall/time_syscall.c +++ b/syscall/time_syscall.c @@ -356,13 +356,18 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp) { int ret; struct timespec srqtp; - struct timespec srmtp = { 0 }; + struct timespec srmtp; if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) { errno = EFAULT; return -EFAULT; } + if (rmtp && LOS_ArchCopyFromUser(&srmtp, rmtp, sizeof(struct timespec))) { + errno = EFAULT; + return -EFAULT; + } + ret = nanosleep(&srqtp, rmtp ? &srmtp : NULL); if (ret < 0) { return -get_errno();