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:
parent
4adc15e630
commit
9458de9ac6
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue