fix: nanosleep 接口的rmtp参数被错误清零

posix/linux 标准:
nanosleep 使线程进入到了可被信号中断的状态,当线程睡眠被信号
中断,线程回复运行态时,若rmtp不为NULL,则会将sleep剩余的时间
记录在rmtp参数中返回,但是如果线程sleep过程中未被信号唤醒,
则忽略该参数。

由于鸿蒙中nanosleep是不可被打断的,即rmtp应该被忽略,而不是清零。

Close #I41U0R
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I6622eb43d6782c2b53b99d9df5cfff5f5e1ed79c
This commit is contained in:
zhushengle 2021-07-22 19:56:01 +08:00
parent 4adc15e630
commit 9458de9ac6
1 changed files with 6 additions and 1 deletions

View File

@ -356,13 +356,18 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
{ {
int ret; int ret;
struct timespec srqtp; struct timespec srqtp;
struct timespec srmtp = { 0 }; struct timespec srmtp;
if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) { if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) {
errno = EFAULT; errno = EFAULT;
return -EFAULT; return -EFAULT;
} }
if (rmtp && LOS_ArchCopyFromUser(&srmtp, rmtp, sizeof(struct timespec))) {
errno = EFAULT;
return -EFAULT;
}
ret = nanosleep(&srqtp, rmtp ? &srmtp : NULL); ret = nanosleep(&srqtp, rmtp ? &srmtp : NULL);
if (ret < 0) { if (ret < 0) {
return -get_errno(); return -get_errno();