* Edge triggered epoll with pts devices acts as level triggered
@ 2005-08-12 11:19 Adam Langley
2005-08-12 17:30 ` Adam Langley
2005-08-13 10:30 ` Heikki Orsila
0 siblings, 2 replies; 3+ messages in thread
From: Adam Langley @ 2005-08-12 11:19 UTC (permalink / raw)
To: linux-kernel
(please cc me on replies)
Waiting for edge triggered events (with EPOLLET) on pseudo terminal
devices appears to act as if it were level triggered; when data is
ready the fd is always returned by epoll_wait.
You can test this with the code below. Compile, run and press return.
If edge triggering is working correctly a single event will be
generated, otherwise a never ending stream will start.
This works *correctly* at a real terminal, but fails for pseudo
terminals (specifically an xterm). As far as I can test with other
terminals and ssh this is a general problem with pseudo terminals.
% uname -a
Linux ice 2.6.12 #4 SMP Sun Jul 31 11:42:15 BST 2005 i686 Pentium II
(Deschutes) GenuineIntel GNU/Linux
(vanilla kernel sources)
% cat et2.c
#include <sys/epoll.h>
#include <unistd.h>
#include <string.h>
int
main(int argc, char **argv) {
const int epoll_fd = epoll_create(4);
struct epoll_event ev;
struct epoll_event events[4];
memset(&ev, 0, sizeof(ev));
ev.events = EPOLLIN | EPOLLET;
epoll_ctl(epoll_fd, EPOLL_CTL_ADD, 0, &ev);
for (;;) {
epoll_wait(epoll_fd, events, 4, -1);
write(1, ".", 1);
}
}
Thanks
AGL
--
Adam Langley agl@imperialviolet.org
http://www.imperialviolet.org (+44) (0)7906 332512
PGP: 9113 256A CC0F 71A6 4C84 5087 CDA5 52DF 2CB6 3D60
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Edge triggered epoll with pts devices acts as level triggered
2005-08-12 11:19 Edge triggered epoll with pts devices acts as level triggered Adam Langley
@ 2005-08-12 17:30 ` Adam Langley
2005-08-13 10:30 ` Heikki Orsila
1 sibling, 0 replies; 3+ messages in thread
From: Adam Langley @ 2005-08-12 17:30 UTC (permalink / raw)
To: linux-kernel
On 8/12/05, Adam Langley <alangley@gmail.com> wrote:
> Waiting for edge triggered events (with EPOLLET) on pseudo terminal
> devices appears to act as if it were level triggered; when data is
> ready the fd is always returned by epoll_wait.
This occurs because writing to the terminal happens to cause a read
event to occur for pseudo terminals, but not for real terminals. This
is much less of a problem than the orginal message would suggest.
AGL
--
Adam Langley agl@imperialviolet.org
http://www.imperialviolet.org (+44) (0)7906 332512
PGP: 9113 256A CC0F 71A6 4C84 5087 CDA5 52DF 2CB6 3D60
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Edge triggered epoll with pts devices acts as level triggered
2005-08-12 11:19 Edge triggered epoll with pts devices acts as level triggered Adam Langley
2005-08-12 17:30 ` Adam Langley
@ 2005-08-13 10:30 ` Heikki Orsila
1 sibling, 0 replies; 3+ messages in thread
From: Heikki Orsila @ 2005-08-13 10:30 UTC (permalink / raw)
To: Linux Kernel Mailing List; +Cc: Adam Langley
Adam Langley wrote:
> epoll_wait(epoll_fd, events, 4, -1);
> write(1, ".", 1);
The test case is faulty. write will trigger the event again infinitely.
fds 0 and 1 are the same in many cases. Try this:
$ ./epolltest > foo
Now you will only get 1 trigger for each input.
--
Heikki Orsila Barbie's law:
heikki.orsila@iki.fi "Math is hard, let's go shopping!"
http://www.iki.fi/shd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-08-13 10:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-12 11:19 Edge triggered epoll with pts devices acts as level triggered Adam Langley
2005-08-12 17:30 ` Adam Langley
2005-08-13 10:30 ` Heikki Orsila
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox