can Inotify and Select calls be merged?

I want to wait on either a file change or socket input. Both of these thinsg will happen rarely and I would rather throw them both into the same thread rather then messing with seperate threads for them, just to avoid a little 'clutter'. Since the Inotify_init seems to provide a file descripter I had thought that I could pass it into select in much the same way I pass in a socket and select would effectiely monitor both. However, I tried to google it and found no examples anywhere of that happening, and it seems if it's possible to do there would be an example of it happening somewhere out there on the internet.

Can anyone verify if I can pass a descripter from INotify into a select method like I would a socket? Or if there is any other blocking method that would listen for both file and socket updates?

Thanks

Answers


This is generally the way Unix devices work. Once you have the file descriptor, you can pass it to select/poll/epoll (you should prefer epoll on Linux systems). But, the documentation for inotify explicitly states that it is select-able. So, if you find that it doesn't work, you can file a bug.

You can use inotify_init1 and pass IN_NONBLOCK as a flag to open the descriptor in non-blocking mode.


Need Your Help

Extract PHP codes into Separate file

php html

Can anyone help me to extract the following php codes into a separate file? Below is the code:

Silverlight: Enterprise-grade push notifications

wcf silverlight notifications scalability

We are building a Silverlight-based system in the financial domain. We need to push notifications/stream data from the server to the Silverlight client. We use Silverlight 4 for the client and Wind...