c - file descriptor polling -


I have created a program in which I want to vote on the file descriptor of the file which I am opening in the program.

  define # file "help" int main () {int ret1; Structure selection FD FD [1]; Rate 1 = open (file, o_ CREAT); FDS [0]. FD = rate 1; FDS [0] .events = POLLIN; While (1) {Voting (FDS, 1, -1); If (FDS [0]. Rivets and Palin) printf ("polishing"); } Return 0; }  

It's going in the infinite loop. I hope to run a loop when there are some file operations. (Its an ASCII file) plz help

choice () doesn actually 'Do not work on opened files Since read () will not be blocked on a file, poll () will always return that you can read non-blocking from the file.

This will work on (approximate) characters' devices, named pipes ** or sockets, however, after those blocks, when you have no data available then read them () Says. (You also need to actually read that data, or the polling will tell you repeatedly that the data is available)

To "vote" a rising / shrinking file, see human Inotify or fstat () in a loop using your coding.

* Block device is a story different; While technically reading from HardDisk can block up to 10 ms or more, this is not considered as blocked I / O in Linux. Also see


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -