1 '\" te
   2 .\"  Copyright (c) 2014, Joyent, Inc. All Rights Reserved.
   3 .\"  This file and its contents are supplied under the terms of the
   4 .\"  Common Development and Distribution License ("CDDL"), version 1.0.
   5 .\"  You may only use this file in accordance with the terms of version
   6 .\"  1.0 of the CDDL.
   7 .\"
   8 .\"  A full copy of the text of the CDDL should have accompanied this
   9 .\"  source.  A copy of the CDDL is also available via the Internet at
  10 .\"  http://www.illumos.org/license/CDDL.
  11 .TH EPOLL_WAIT 3C "Apr 17, 2014"
  12 .SH NAME
  13 epoll_wait, epoll_pwait \- wait for epoll events
  14 .SH SYNOPSIS
  15 .nf
  16 #include <sys/epoll.h>
  17 
  18 \fBint\fR \fBepoll_wait\fR(\fBint\fR \fIepfd\fR, \fBstruct epoll_event *\fR\fIevents\fR,
  19      \fBint\fR \fImaxevents\fR, \fBint\fR \fItimeout\fR);
  20 .fi
  21 
  22 .LP
  23 .nf
  24 \fBint\fR \fBepoll_pwait\fR(\fBint\fR \fIepfd\fR, \fBstruct epoll_event *\fR\fIevents\fR,
  25      \fBint\fR \fImaxevents\fR, \fBint\fR \fItimeout\fR,
  26      \fBconst sigset_t *\fR\fIsigmask\fR);
  27 .fi
  28 
  29 .SH DESCRIPTION
  30 The \fBepoll_wait()\fR function waits for events on the \fBepoll\fR(5)
  31 instance specified by \fIepfd\fR.  The \fIevents\fR parameter must point to
  32 an array of \fImaxevents\fR \fIepoll_event\fR structures to be
  33 filled in with pending events.  The \fItimeout\fR argument specifies the
  34 number of milliseconds to wait for an event if none is pending.  A
  35 \fItimeout\fR of -1 denotes an infinite timeout.
  36 
  37 The \fBepoll_pwait()\fR is similar to \fBepoll_wait()\fR, but takes an
  38 additional \fIsigmask\fR argument that specifies the desired signal mask
  39 when \fBepoll_pwait()\fR is blocked.  It is equivalent to atomically
  40 setting the signal mask, calling \fBepoll_wait()\fR, and restoring the
  41 signal mask upon return, and is therefore similar to the relationship
  42 between \fBselect\fR(3C) and \fBpselect\fR(3C).
  43 
  44 .SH RETURN VALUES
  45 Upon successful completion, \fBepoll_wait()\fR and \fBepoll_pwait()\fR return
  46 the number of events, or 0 if none was pending and \fItimeout\fR milliseconds
  47 elapsed.  If an error occurs, -1 is returned and errno is set to indicate
  48 the error.
  49 
  50 .SH ERRORS
  51 The \fBepoll_wait()\fR and \fBepoll_pwait()\fR functions will fail if:
  52 .sp
  53 .ne 2
  54 .na
  55 \fB\fBEBADF\fR\fR
  56 .ad
  57 .RS 10n
  58 \fIepfd\fR is not a valid file descriptor.
  59 .RE
  60 
  61 .sp
  62 .ne 2
  63 .na
  64 \fB\fBEFAULT\fR\fR
  65 .ad
  66 .RS 10n
  67 The memory associated with \fIevents\fR was not mapped or was not writable.
  68 .RE
  69 
  70 .sp
  71 .ne 2
  72 .na
  73 \fB\fBEINTR\fR\fR
  74 .ad
  75 .RS 10n
  76 A signal was received during the \fBepoll_wait()\fR or \fBepoll_pwait()\fR.
  77 .RE
  78 
  79 .sp
  80 .ne 2
  81 .na
  82 \fB\fBEINVAL\fR\fR
  83 .ad
  84 .RS 10n
  85 Either \fIepfd\fR is not a valid \fBepoll\fR(5) instance or \fImaxevents\fR
  86 is not greater than zero.
  87 .RE
  88 
  89 .sp
  90 .SH NOTES
  91 The \fBepoll\fR(5) facility is implemented for purposes of offering
  92 compatibility for Linux-borne applications; native
  93 applications should continue to prefer using event ports via the
  94 \fBport_create\fR(3C), \fBport_associate\fR(3C) and \fBport_get\fR(3C)
  95 interfaces.  See \fBepoll\fR(5) for compatibility details and restrictions.
  96 
  97 .SH SEE ALSO
  98 \fBepoll_create\fR(3C), \fBepoll_ctl\fR(3C),
  99 \fBport_create\fR(3C), \fBport_associate\fR(3C), \fBport_get\fR(3C),
 100 \fBpselect\fR(3C), \fBepoll\fR(5)