linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* epoll vs stdin/stdout
@ 2003-07-07 15:48 Eric Varsanyi
  2003-07-07 18:57 ` Davide Libenzi
  0 siblings, 1 reply; 23+ messages in thread
From: Eric Varsanyi @ 2003-07-07 15:48 UTC (permalink / raw)
  To: linux-kernel; +Cc: davidel

It seems reasonable to register for read events on stdin and write events
on stdout.  In an earlier posting on the epoll API it was asserted that 
anyone registering for events on 2 fd's that shared the same file * was 
asking for trouble.

I can imagine many apps that might want to proxy async traffic thru
stdin/stdout, what is the intended general solution for this with epoll?

FWIW in my app I'm just assuming that fd0 is a dup of fd1 if EPOLL_CTL_ADD 
on fd1 fails with EEXISTS, then I EPOLL_CTL_MOD on fd0 to add the write event.
This seems like a bit of a hack tho.

Example, 2nd ADD fails with EEXIST:

int
main(int ac, char **av)
{
        int pfd;
        struct epoll_event ev;

        pfd = epoll_create(10);
        ev.events = EPOLLIN | EPOLLET;
        ev.data.u32 = 0xdeadbee0;
        if (epoll_ctl(pfd, EPOLL_CTL_ADD, 0, &ev) < 0) {
                perror("EPOLL_CTL_ADD stdin");
                exit(1);
        }
        ev.events = EPOLLOUT | EPOLLET;
        ev.data.u32 = 0xdeadbee1;
        if (epoll_ctl(pfd, EPOLL_CTL_ADD, 1, &ev) < 0) {
                perror("EPOLL_CTL_ADD stdout");
                exit(1);
        }
}

-Eric Varsanyi

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2003-07-08 18:25 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-07 15:48 epoll vs stdin/stdout Eric Varsanyi
2003-07-07 18:57 ` Davide Libenzi
2003-07-07 19:47   ` Eric Varsanyi
2003-07-07 20:03     ` Jamie Lokier
2003-07-07 20:18       ` Miquel van Smoorenburg
2003-07-07 21:20         ` H. Peter Anvin
2003-07-07 22:11       ` Davide Libenzi
2003-07-08  0:24         ` Jamie Lokier
2003-07-08  0:23           ` Davide Libenzi
2003-07-07 22:12     ` Davide Libenzi
2003-07-07 23:26       ` Davide Libenzi
2003-07-08  0:32         ` Jamie Lokier
2003-07-08  0:32           ` Davide Libenzi
2003-07-08  0:52             ` Jamie Lokier
2003-07-08  1:13               ` Davide Libenzi
2003-07-08 12:34                 ` Jamie Lokier
2003-07-08 13:51                   ` Jamie Lokier
2003-07-08 15:20                     ` Davide Libenzi
2003-07-08 15:46         ` Eric Varsanyi
2003-07-08 15:42           ` Davide Libenzi
2003-07-08 16:02             ` Eric Varsanyi
2003-07-08 17:06               ` Davide Libenzi
2003-07-08 18:40                 ` Eric Varsanyi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).