code使用Unix的概念在C语言目录监控 [英] Code for directory monitor using Unix concepts in C language
问题描述
在一台服务器,一个进程监视在Unix文件系统中的文件。
On a server, a process monitors the files in a Unix file system.
如果一个客户端发送的文件名进行监控,服务器报告发送给客户端的文件是否得到更改或删除。
If a client sends the file name to be monitored, the server has to send the report to the client whether that file got changed or deleted.
有关服务器 - 客户端通信,我们应该使用消息队列或插槽。
For server-client communication, we should use either message queues or sockets.
有关文件中的每一个变化,服务器必须通知改变。
For every change in the file, the server has to notify that change.
有关的所有文件中的所有变化,服务器必须维护一个日志文件,使用户可以通过命令行界面查看。
For all changes in all files, the server has to maintain one logfile so that user can view it through the command line interface.
服务器可以使用两个线程:一个用于通信,另一个用于监视
Server could use two threads: one for communication, the other for monitoring.
你怎么能做到这一点有效?
How can you do this efficiently?
推荐答案
看一看了inotify HTTP: //en.wikipedia.org/wiki/Inotify - 仅适用于Linux恐怕
Have a look at inotify at http://en.wikipedia.org/wiki/Inotify - linux only I'm afraid.
BSD有kqueue的 - 见 http://en.wikipedia.org/wiki/Kqueue
BSD has kqueue - see http://en.wikipedia.org/wiki/Kqueue.
这篇关于code使用Unix的概念在C语言目录监控的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!