lkml.org 
[lkml]   [2003]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectepoll vs stdin/stdout
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.074 / U:0.704 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site