{"id":363812,"date":"2024-05-21T02:04:00","date_gmt":"2024-05-21T02:04:00","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=363812"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=363812","title":{"rendered":"<span>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Inotify<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\u0421\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432 \u041e\u0421 Linux \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c \u0421++. \u0422\u0430\u043a \u043a\u0430\u043a \u0447\u0438\u0441\u0442\u044b\u0439 \u0421++, Qt \u0441 \u0435\u0433\u043e <a href=\"https:\/\/habr.com\/ru\/sandbox\/47189\/\">QFileSystemWatcher<\/a> \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043f\u0430\u0434\u0430\u043b, \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c <a href=\"https:\/\/doc.qt.io\/qt-5\/qobject.html\" rel=\"nofollow noopener noreferrer\">QObject<\/a>. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u0438\u043d\u0443\u043a\u0441\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 Inotify.<br \/>  <a name=\"habracut\"><\/a><br \/>  Inotify \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0437\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0435\u0439 \u0438\u043b\u0438 \u0444\u0430\u0439\u043b\u043e\u043c, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u044f \u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u044f. \u0412\u0441\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430. \u0424\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0442\u0438\u043f\u0430 int. <\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0440\u0430\u0431\u043e\u0442\u0430 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ol>\n<li>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b><i>inotify_init()<\/i><\/b> \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440<\/li>\n<li> \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043b\u044f \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439<\/li>\n<li> \u041e\u0436\u0438\u0434\u0430\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435<\/li>\n<li> \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0436\u0434\u0430\u0442\u044c \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435<\/li>\n<li> \u041f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0438\u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443.<\/li>\n<\/ol>\n<p>  \u0412 API Inotify \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b:<\/p>\n<p>  <b><i>inotify_init()<\/i><\/b> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 inotify \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <b><i>inotify_init1(int flags)<\/i><\/b>. \u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u043b\u0430\u0433 0 \u0438\u043b\u0438 \u0444\u043b\u0430\u0433\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b, \u0442\u043e <br \/>  <b><i>inotify_init1(int flags)<\/i><\/b> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a <b><i>inotify_init()<\/i><\/b>. \u0422\u0430\u043a \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u043b\u0430\u0433\u0438:<br \/>  <i>IN_NONBLOCK<\/i> \u2013 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0432 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0436\u0438\u043c. <br \/>  <i>IN_CLOEXEC<\/i> \u2013 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0444\u043b\u0430\u0433 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438.<\/p>\n<p>  \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <b><i>inotify_add_watch(int fd, const char *pathname, uint32_t mask)<\/i><\/b> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 inotify, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442<i> mask<\/i> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0438\u043f \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u043c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u043c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u043b\u0430\u0433\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c:<\/p>\n<p>  <i>IN_ACCESS<\/i> \u2014 \u0424\u0430\u0439\u043b \u0431\u044b\u043b \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d (read())<br \/>  <i>IN_ATTRIB<\/i> \u2014 \u041c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u044b <br \/>  <i>IN_CLOSE_WRITE<\/i> \u2014 \u0424\u0430\u0439\u043b \u0431\u044b\u043b \u043e\u0442\u043a\u0440\u044b\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043a\u0440\u044b\u0442<br \/>  <i>IN_CLOSE_NOWRITE<\/i> \u2014 \u0424\u0430\u0439\u043b \u0431\u044b\u043b \u043e\u0442\u043a\u0440\u044b\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043a\u0440\u044b\u0442 <br \/>  <i>IN_CREATE<\/i> \u2014 \u0424\u0430\u0439\u043b\/\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0437\u0434\u0430\u043d \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 <br \/>  <i>IN_DELETE<\/i> \u2014 \u0424\u0430\u0439\u043b\/\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0443\u0434\u0430\u043b\u0435\u043d \u0438\u0437 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 <br \/>  <i>IN_DELETE_SELF<\/i> \u2014 \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b\/\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0435\u043d <br \/>  <i>IN_MODIFY<\/i> \u2014 \u0424\u0430\u0439\u043b \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0435\u043d <br \/>  <i>IN_MOVE_SELF<\/i> \u2014 \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b\/\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0431\u044b\u043b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d <br \/>  <i>IN_MOVED_FROM<\/i> \u2014 \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b\/\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0431\u044b\u043b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d \u0438\u0437 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 <br \/>  <i>IN_MOVED_TO<\/i> \u2014 \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b\/\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0431\u044b\u043b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d \u0432 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <br \/>  <i>IN_OPEN<\/i> \u2014 \u0424\u0430\u0439\u043b \u0431\u044b\u043b \u043e\u0442\u043a\u0440\u044b\u0442 <br \/>  <i>IN_ALL_EVENTS<\/i> \u2014 \u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432\u0432\u043e\u0434\u0430 <br \/>  <i>IN_MOVE<\/i> \u2014 \u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f IN_MOVED_FROM | IN_MOVED_TO <br \/>  <i>IN_CLOSE<\/i> \u2014 \u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f IN CLOSE WRITE | IN CLOSE NOWRITE <br \/>  <i>IN_DONT_F\u041eLLOW<\/i> \u2014 He \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Linux 2.6.15) <br \/>  <i>IN_MASK_ADD<\/i> \u2014 \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u043c\u0430\u0441\u043a\u0443 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u0430 <i>pathname<\/i> <br \/>  <i>IN_ONESHOT<\/i> \u2014 \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u0430 pathname \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <br \/>  <i>IN_ONLYDIR<\/i> \u2014 \u041e\u0448\u0438\u0431\u043a\u0430, \u0435\u0441\u043b\u0438 pathname \u043d\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Linux 2.6.15)<\/p>\n<p>  \u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <b><i>inotify_rm_watch()<\/i><\/b>.<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <b><i>read()<\/i><\/b> \u0447\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445.<\/p>\n<p>  <b><i>close()<\/i><\/b> \u2014 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0438\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f. \u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 inotify \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f, \u0432\u0441\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044e\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u044f\u0434\u0440\u043e \u043c\u043e\u0433\u043b\u043e \u0438\u0445 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0418\u0442\u0430\u043a \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 <i>\u00abhome\/user\/dev\u00bb<\/i>. \u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u044d\u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435. <\/p>\n<pre><code class=\"cpp\">#define MAX_EVENTS 1024 \/*\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430 \u043e\u0434\u0438\u043d \u0440\u0430\u0437*\/ #define LEN_NAME 16 \/*\u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u0438\u043d\u0430 \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 16 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432*\/ #define EVENT_SIZE  ( sizeof (struct inotify_event) ) \/*\u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u044f*\/ #define BUF_LEN     ( MAX_EVENTS * ( EVENT_SIZE + LEN_NAME )) \/*\u0431\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445*\/  int main(int argc, char *argv[]) {     int length, i = 0, wd;     int fd;     char buffer[BUF_LEN];       \/* \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Inotify*\/     fd = inotify_init1(0);     if ( fd &lt; 0 ) {         perror( \"Couldn't initialize inotify\");     }     const char path[] = \"\/home\/user\/dev\";      \/* \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438*\/     wd = inotify_add_watch(fd, path, IN_CLOSE | IN_MODIFY);     if (wd == -1)     {         printf(\"Couldn't add watch to %s\\n\",path);     }     else     {         printf(\"Watching:: %s\\n\",path);     }      while(1)     {         i = 0;   \/* \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430*\/         length = read( fd, buffer, BUF_LEN );         if ( length &lt; 0 ) {             perror( \"read\" );         }          while ( i &lt; length ) {         struct inotify_event *event = ( struct inotify_event * ) &amp;buffer[ i ];         if ( event->len ) {             if ( event->mask &amp; IN_CLOSE) {                 if (event->mask &amp; IN_ISDIR)                     printf( \"The directory %s was closed.\\n\", event->name );                 else                     printf( \"The file %s was closed with WD %d\\n\", event->name, event->wd );             }             if ( event->mask &amp; IN_MODIFY) {                 if (event->mask &amp; IN_ISDIR)                     printf( \"The directory %s was modified.\\n\", event->name );                 else                     printf( \"The file %s was modified with WD %d\\n\", event->name, event->wd );             }                 i += EVENT_SIZE + event->len;             }         }     }     \/* \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432*\/     inotify_rm_watch( fd, wd );     close( fd );     return 0; } <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/782742\/\"> https:\/\/habr.com\/ru\/articles\/782742\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\u0421\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432 \u041e\u0421 Linux \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c \u0421++. \u0422\u0430\u043a \u043a\u0430\u043a \u0447\u0438\u0441\u0442\u044b\u0439 \u0421++, Qt \u0441 \u0435\u0433\u043e <a href=\"https:\/\/habr.com\/ru\/sandbox\/47189\/\">QFileSystemWatcher<\/a> \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043f\u0430\u0434\u0430\u043b, \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c <a href=\"https:\/\/doc.qt.io\/qt-5\/qobject.html\" rel=\"nofollow noopener noreferrer\">QObject<\/a>. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u0438\u043d\u0443\u043a\u0441\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 Inotify.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-363812","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/363812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=363812"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/363812\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=363812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=363812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=363812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}