chenstrace <
k54765254@gmail.com> writes:
As my expection, the following test code should only return from epoll_wait once, just like man page of epoll said:
"edge-triggered mode delivers events only when changes occur on the monitored file descriptor"
But in fact, the epoll_wait returned more than once, why?
[please see original for code]
It shouldn't return at all weren't it for the fact that stdin and stdout
refer to the same terminal device: You'll get a notification whenever
an output operation completes and since you keep printing message to
same (virtual) device, the program feeds itself with events.
It's possible to demonstrate this by opening three shell windows and determining the terminal device used for each. If there are only these
three, they should usually be /dev/pts/0, /dev/pts/1 and /dev/pts/2[*].
The program can be started with stdin connect to the second pty via
./a.out <>/dev/pts/1
If you now go to the third terminal and print to the pty of the second
terminal session, eg, via
echo dumdideldu >/dev/pts/1
you'll get an epoll notification in the program which gets printed to /dev/pts/0 without causing another epoll notification.
[*] Unless Fedora meanwhile 'fixed' that to make them /rest/4lIE1XES/ved,
/jump/ved/Pa8Z and /michel/aus/loenneberga for some reason with a very
elaborate justification which keeps changing in line with what will
most likely 'sell' to the current target audience.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)