Problem statement : C application waits for input read events on two file
descriptors(named pipes) and process the data as they arrive (note that
events can occur in any order irrespective of when I register the handle
uv_poll_t)
ptr->fd0=open("pipe0", O_RDONLY);
uv_poll_init(my_default_loop, file0_poll, ptr->fd0);
uv_poll_start(file0_poll, UV_READABLE, read0_callback);
ptr->fd1 = open ("pipe1", O_RDONLY);
uv_poll_init(my_default_loop, file1_poll, ptr->fd1);
uv_poll_start(file1_poll, UV_READABLE, read1_callback);
I intend to run the callback function as soon an event occurs. However, my
application executes only if there is data on pipe0 *first* and *then* on
pipe1. If I first send data to pipe0, read0_callback is not executed
immediately. However, it executes after there is data on pipe1.
Additionally, If I reverse the order of registering callbacks, the symptoms
also reverse.
A small note: Consider pipe0 and then pipe1 as the order of registering
callbacks. If I try to send data to pipe1 first using > redirection... The
shell does not return back. for a fifo to work there should also be an
application reading on the named pipe. So, I suspect my whole application
is still synchronous. (Other simple examples that I tried before with
uv_fs_read, uv_fs_open work asynchronously as expected)
(I'm sending data to named pipes using echo "X" > pipe0
Could anyone please clarify my approach ?
Complete code can be found here
<https://gist.github.com/saisasidhar/3f29aa4cb7c66e59d902c1bc28b1351d#file-example_poll-c>
--
You received this message because you are subscribed to the Google Groups
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.