为什么“暂停”?系统调用总是返回-1?
或者,为什么我们不能简单地将暂停声明为:
#include <unistd.h>
void pause(void);
因为暂停的返回值是没有意义的。
or, why can't we simply declare pause as:
#include <unistd.h>
void pause(void);
since the return value of pause is meaningless.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自
pause
每个被中断的系统调用都会得到
EINTR
(或者在特殊情况下得到ERESTART
)。我认为没有理由让pause
成为例外!当然,您可以在代码中编写
(void)pause ();
来忽略结果。From man page of
pause
Every syscall which is interrupted is getting
EINTR
(orERESTART
in peculiar cases). I see no reason to makepause
an exception!Of course you are free to write
(void) pause ();
in your code to ignore the result.