Hi Andrew, Thanks for your prompt. Moments ago, I wrote a client to open the .fifo file and write data to it and finally drive the event-loop run!
I guess I must further my research into the kernel before I completely understand how epoll/select etc cooperate with file descriptor:( Thanks for your help Harvey 2011/8/3 Andrew W. Nosenko <andrew.w.nose...@gmail.com> > On Wed, Aug 3, 2011 at 15:57, zhihua che <zhihua....@gmail.com> wrote: > > Hi, Adrian, > > Thanks for your reply. However, what you said makes me more > confused:( > > You mean the mechanism behind libevent like epoll doesn't support > > regular file descriptor? I'm not sure whether you're right, but looking > into > > poll/select/etc technically support regular file descriptors. There > no error to pass regular FDs to them. It just useless because regular > file always available for read and always available for write > (assuming that file opened for read and write respectively). > Therefore, callbacks bound to such descriptors will be called at ever > event-loop round. > > > the application sample given by the libevent official > > website, http://monkey.org/~provos/libevent/event-test.c, I found this > > sample using libevent on the local file 'event.fifo', and this is where > my > > confusion came from, so I guess I must further my reading to find more > > proof:) > > 'event.fifo' in event-test.c is not a regular file. It is FIFO (named > pipe, special filesystem object). You can see it by inspecing > following snippet: > > around lines 96-108: if filesystem object with given name exists, and > is a regular file, then report error and exit; otherwise create or > recreate it as FIFO: > > if (lstat(fifo, &st) == 0) { > if ((st.st_mode & S_IFMT) == S_IFREG) { > errno = EEXIST; > perror("lstat"); > exit(1); > } > } > > unlink(fifo); > if (mkfifo(fifo, 0600) == -1) { > perror("mkfifo"); > exit(1); > } > > -- > Andrew W. Nosenko <andrew.w.nose...@gmail.com> > *********************************************************************** > To unsubscribe, send an e-mail to majord...@freehaven.net with > unsubscribe libevent-users in the body. >