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?
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.