Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 马赫能等到()被信号打断吗?_Macos_Signals - Fatal编程技术网

Macos 马赫能等到()被信号打断吗?

Macos 马赫能等到()被信号打断吗?,macos,signals,Macos,Signals,sleep()可能比指定时间更早工作,因为它可以被信号唤醒 手册页说明: sleep()函数暂停调用线程的执行,直到秒数已过或有信号传递给线程,其操作是调用信号捕获函数或终止线程或进程 没有mach\u wait\u until()的手册页。。它也能被信号中断吗?在一个旧的苹果邮件列表上,有人声称不会,但我遇到了一个只有当它这样做时才有意义的情况。这是在任何地方记录的,还是有人对这个话题有更多的见解?看起来可以 当然没有文档,这不是苹果编写文档的方式 但幸运的是,我们可以用苹果开源xnu内核检查

sleep()
可能比指定时间更早工作,因为它可以被信号唤醒

手册页说明:

sleep()函数暂停调用线程的执行,直到秒数已过或有信号传递给线程,其操作是调用信号捕获函数或终止线程或进程

没有
mach\u wait\u until()的手册页。
。它也能被信号中断吗?在一个旧的苹果邮件列表上,有人声称不会,但我遇到了一个只有当它这样做时才有意义的情况。这是在任何地方记录的,还是有人对这个话题有更多的见解?

看起来可以

当然没有文档,这不是苹果编写文档的方式

但幸运的是,我们可以用苹果开源xnu内核检查它:

我想说我们对文件xnu-7195.50.7.100.1\osfmk\kern\clock.c很感兴趣 存在一个陷阱,该陷阱通过此类调用实现mach_wait_,直到:

wresult = assert_wait_deadline_with_leeway((event_t)mach_wait_until_trap, THREAD_ABORTSAFE,
    TIMEOUT_URGENCY_USER_NORMAL, deadline, 0);
xnu-7195.50.7.100.1\osfmk\kern\kern_types.h中声明了此处的线程_ABORTSAFE,并提供了一些有用的注释:

* THREAD_ABORTSAFE:
 *    Wait will end if someone explicitly wakes up the thread, the wait timeout
 *    expires, the current thread is being terminated, if any signal arrives for
 *    the task, or thread_abort_safely() is called on the thread.
 *
 *    Using this value means that you are willing to be interrupted in the face
 *    of any user signal, and safely rewind the thread back to the user/kernel
 *    boundary.  Many syscalls will try to restart the operation they were performing
 *    after the signal has been handled.
 *
 *    You must provide this value for any unbounded wait - otherwise you will
 *    pend user signals forever.