[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] [libevent-usr] When is a [regular file descriptor] readable or writable?

On Wed, Aug 3, 2011 at 15:57, zhihua che <zhihua.che@xxxxxxxxx> 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;

	if (mkfifo(fifo, 0600) == -1) {

Andrew W. Nosenko <andrew.w.nosenko@xxxxxxxxx>
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.