Bug 203773 - KQueue Man Page Error - kevent - EINTR listed twice
Summary: KQueue Man Page Error - kevent - EINTR listed twice
Status: Closed Not A Bug
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Konstantin Belousov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-14 16:15 UTC by Michael Cress
Modified: 2019-02-13 09:08 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Cress 2015-10-14 16:15:42 UTC
Below is an excerpt from the KQUEUE's Error section for kevent():

[EINTR]		A signal was delivered before the timeout expired and
			before any events were placed on the kqueue for
			return.

[EINTR]		A cancellation request was delivered to	the thread,
			but not	yet handled.


This looks like an error and, if not, it is confusing. If it isn't, could the descriptions be consolidated into one statement?
Comment 1 Benjamin Kaduk freebsd_committer freebsd_triage 2015-10-15 02:44:31 UTC
This double-EINTR was added in r280818 by kib.  I cannot say with confidence that the correct thing to do is coalesce the two descriptions into one, due to the claim added later in the manual page that "When kevent() call fails with EINTR error, all changes in the changelist have been applied."  Kostik, what do you think?
Comment 2 Konstantin Belousov freebsd_committer freebsd_triage 2015-10-15 08:33:57 UTC
(In reply to Benjamin Kaduk from comment #1)
It is usual practice to list same error code several times when the reasons for errors reported are unrelated.  Look at other man pages, my first (almost random) selection of open(2) gave ample source of examples, e.g. for ENOENT, EACCESS, EPERM and others.

In other words, there is nothing to fix, since the descriptions of the two listed EINTR reasons are obviously different.  More, the text follows the existing practice.
Comment 3 Michael Cress 2015-10-15 15:10:57 UTC
This is deviating from the original bug report and is an engineering question, but shouldn't there be separate error codes when the root cause of an error differs? Otherwise, you start down the path of branched error code analysis.

Example:

switch( errno )
{
   case EINTR:
   {

      if( /*Check condition one*/ )
      {
      }
      else if( /*Condition 2*/ )
      {
      }
      break;
   }
};
Comment 4 David Bright freebsd_committer freebsd_triage 2019-02-12 21:10:35 UTC
(In reply to Michael Cress from comment #3)

I believe that the behavior of kevent() is in conformance with POSIX (IEEE Std 1003.1-2001) here, although admittedly it probably doesn't //need// to follow that standard since kqueue()/kevent() is not defined by POSIX. Anyway, returning EINTR seems to make sense from this text:

The side effects of acting upon a cancellation request while suspended during a call of a function are the same as the side effects that may be seen in a single-threaded program when a call to a function is interrupted by a signal and the given function returns [EINTR]. Any such side effects occur before any cancellation cleanup handlers are called.

I would suggest that this bug be closed, "Works as Intended".
Comment 5 Konstantin Belousov freebsd_committer freebsd_triage 2019-02-13 09:08:54 UTC
Cancellation is only checked after the syscall return.  In other words, the statement that EINTR return implies that all changes are applied, is true.