It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
7年前关闭。
或者,为什么我们不能简单地声明暂停为:
#include <unistd.h>
void pause(void);

因为pause的返回值没有意义。

最佳答案

man page of pause

RETURN VALUE

   pause()  only  returns when a signal was caught and the signal-catching
   function returned.  In this case pause() returns -1, and errno  is  set
   to EINTR.

每个被中断的系统调用都会得到EINTR(在特殊情况下是ERESTART)我认为没有理由让pause成为一个例外!
当然,您可以在代码中编写(void) pause ();来忽略结果。

关于c - 为什么“暂停”系统调用总是返回-1? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8255107/

10-11 15:33