Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, about poll() API int poll(struct pollfd *fds, nfds_t nfds, int timeout); I have a question, how to let the thread waiting on poll() return immediately? perhaps a answer is: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2013
    Posts
    1

    about poll() API


    Hello,
    about poll() API
    int poll(struct pollfd *fds, nfds_t nfds, int timeout);

    I have a question, how to let the thread waiting on poll() return immediately?
    perhaps a answer is: add a pipe in the poll file list, and
    write something in the pipe.
    however, I think this is not very efficient and
    I hope there is API like this:

    int poll2(struct pollfd *fds, nfds_t nfds, int timeout, Handle event);
    if user wants to return immediately from poll(), signal the event,
    and the poll2 returns a value (e.g:-2, -1 usually is API failed) to
    indicate this result.

    since I am very new to Linux, do I miss something or
    whether it already have a API like this?

    Thanks.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,601
    Look at ppoll() and pselect().
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •