ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have been playing with a piece of code based mostly on Robert Love's article in the Linux journal and the code (which follows) is simply not doing what it is supposed to be doing. Basically, every time select unblocks after an event, the event mask is the same, even though the events are all different. I am quite certain I have missed something very basic but for the life of me I cannot see it. Here is the code:
Please use code tags when you post code - it's much easier to read.
You are thinking of http://www.linuxjournal.com/article/8478 right? In it, there is a section where the event is read - which you seem to miss in your code. Select is used to check if there is data available to read, since the read function will wait till there is some. When you have found out there is data to be read you need to read it. Reading events is a bit complicated as the event structure doesn't have a fixed length. But there is a section in the article explaining how you do it.
Also, in your code, you specify IN_MODIFY|IN_CREATE|IN_DELETE meaning that's the only event you will recieve. If you want all, you can use IN_ALL_EVENTS instead.
Yes I read that part. I think I misunderstood because I thought what he meant was we could use select and that way not get blocked on a read. Later on I did realized that even was not initialized, which is pretty basic error. In any case I sorted it all out now.
I thought I had inserted the code tags but perhaps not; I rarely post on th eforums so the little details escape me. But I will keep it in mind for next time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.