我從來沒有用過C語言。此腳本將偵聽器添加到目錄中,並通過回顯到終端來通知用戶,然後在發生文件事件時退出。我想修改腳本不退出,而是繼續監視文件夾。我認爲最關鍵的可能是這一行:
length = read(fd, buffer, BUF_LEN);
,但我真的不明白是怎麼回事。該read()
功能的描述可能是爲那些誰知道的C真的很好有所幫助:
Using inotify is simple: Create a file descriptor, attach one or more watches (a watch is a path and set of events), and use the read() method to receive event information from the descriptor. Rather than burn scarce cycles, read() blocks until events occur.
但我不屬於這一類。
沒錯。所以讓我困惑的是'while(i
lollercoaster
'read()'直接讀入'buffer'並返回讀取的字節數,它存儲在'length'中。我並不完全確定'while(i
Vache
這是正確的。 inotify可以排隊多個事件,然後'read()'將返回它們。 'while(i