From 0c203c1e5705bc1b858bcde7448785e3cb8e155f Mon Sep 17 00:00:00 2001 From: wanghao-free Date: Wed, 8 Sep 2021 20:04:54 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3nanosleep=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=9A=84rmtp=E5=8F=82=E6=95=B0=E8=A2=AB=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=B8=85=E9=9B=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主干不存在该问题,已解决. nanosleep 使线程进入到了可被信号中断的状态,当线程睡眠被信号 中断,线程回复运行态时,若rmtp不为NULL,则会将sleep剩余的时间 记录在rmtp参数中返回,但是如果线程sleep过程中未被信号唤醒, 则忽略该参数。 由于鸿蒙中nanosleep是不可被打断的,即rmtp应该被忽略,而不是清零。 Close #I48FMT Signed-off-by: wanghao-free --- 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 10ef483c..038b827c 100755 --- a/syscall/time_syscall.c +++ b/syscall/time_syscall.c @@ -355,13 +355,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(); -- GitLab