[問題] poll 一問
請問一下,我由 process1 開了一個文件在 /dec/input 底下,
然後希望能夠從另外一個 process2 改變它的值,進而讓 poll 解除 blocking 的狀態,
也就是希望 poll(mFDs, mFDCount, -1) 能夠在文件有改變的時候跳出來,
做我接下來想完成的動作,
請問我在 process2 該怎麼做才能夠改變它的值讓 poll 跳出呢?
只要單純寫檔就可以了嗎? 可以直接用 write function 透過檔名更改該檔案內容
讓他跳出嗎?
我 process1 寫法如下,希望有經驗的朋友可以回答一下,感謝:)
----------------------------------------------------------------------------
int fd = open("/dev/input/event7", O_RDWR);
struct pollfd *new_mFDs = (pollfd*)realloc(mFDs, sizeof(mFDs[0]) * (mFDCount + 1));
mFDs = new_mFDs;
mFDs[mFDCount].fd = fd;
mFDs[mFDCount].events = POLLIN;
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.87.64.222
※ fantasywater:轉錄至看板 LinuxDev 11/02 20:43