当前位置: 技术问答>linux和unix
linux c中除了轮询的办法 , 还有没有其它方法 较快知道 一个文件的大小改变了
来源: 互联网 发布时间:2016-04-22
本文导语: linux c中 除了轮询的办法 , 还有没有其它方法 较快知道 一个文件的大小改变了 | 试试用 select 函数, select 函数用于实现I/O多路复用,它允许进程指示系统内核等待多个事件中的任何...
linux c中
除了轮询的办法 , 还有没有其它方法 较快知道 一个文件的大小改变了
除了轮询的办法 , 还有没有其它方法 较快知道 一个文件的大小改变了
|
试试用 select 函数,
select 函数用于实现I/O多路复用,它允许进程指示系统内核等待多个事件中的任何一个发生。
你可以自己查查它的用法。
select 函数用于实现I/O多路复用,它允许进程指示系统内核等待多个事件中的任何一个发生。
你可以自己查查它的用法。
|
FAM provides an API applications can use to be notified when specific files or directories are changed. It is intended to be a more efficient and more useful replacement for alternatives such as the poll and select system calls.
FAM is most useful for tools such as graphical file managers, which should always show the current state of the system, even if another tool is used to modify a file. Other possible uses include a mail program monitoring a mailbox for new mail and a daemon monitoring its configuration file for configuration changes.
FAM comes in two parts: fam, the daemon that listens for requests and delivers notification, and libfam, a library client applications can use to communicate with fam.
FAM was developed for SGI's IRIX operating system, and has been used under that environment for several years. The open source version available here is almost identical in functionality and should build on most Unix-like platforms.
FAM uses IRIX's /dev/imon feature to get updates directly from the kernel, making it very efficient. When /dev/imon is not available, FAM falls back to polling mode. Support for Linux's DNotify API has recently been contributed, and it is hoped that support for other operating system's equivalent features (such as FreeBSD's kqueue or Solaris's /dev/poll) will be contributed or developed.
http://savannah.nongnu.org/projects/fam/
FAM is most useful for tools such as graphical file managers, which should always show the current state of the system, even if another tool is used to modify a file. Other possible uses include a mail program monitoring a mailbox for new mail and a daemon monitoring its configuration file for configuration changes.
FAM comes in two parts: fam, the daemon that listens for requests and delivers notification, and libfam, a library client applications can use to communicate with fam.
FAM was developed for SGI's IRIX operating system, and has been used under that environment for several years. The open source version available here is almost identical in functionality and should build on most Unix-like platforms.
FAM uses IRIX's /dev/imon feature to get updates directly from the kernel, making it very efficient. When /dev/imon is not available, FAM falls back to polling mode. Support for Linux's DNotify API has recently been contributed, and it is hoped that support for other operating system's equivalent features (such as FreeBSD's kqueue or Solaris's /dev/poll) will be contributed or developed.
http://savannah.nongnu.org/projects/fam/
|
也许你可以看看inotify,如果内核不支持,可能需要给内核打补丁!
Reference: http://www.ibm.com/developerworks/cn/linux/l-inotify.html
good luck!
Reference: http://www.ibm.com/developerworks/cn/linux/l-inotify.html
good luck!