|
ru.linux- RU.LINUX --------------------------------------------------------------------- From : Bohdan Vlasyuk 2:5020/400 16 Jul 2001 12:49:48 To : All Subject : Re: Kernel 2.0 -------------------------------------------------------------------------------- a.com> From: Bohdan Vlasyuk <bohdan@kivc.vstu.vinnica.ua> alexey.vyskubov@nokia.com wrote: > А про "половину твоих прог" можно конкретнее? #include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <signal.h> #include <linux/fcntl.h> char * FTM; time_t last; void sig_handler(int x) { struct stat buf; if (x == SIGIO) { stat(FTM, &buf); if (buf.st_ctime != last) { printf("file changed.\n"); last = buf.st_ctime; } } } int main(int argc, char *argv[]) { int handle; struct stat buf; if(argc!=2) return -1; FTM=argv[1]; stat(FTM, &buf); last = buf.st_ctime; signal(SIGIO, sig_handler); handle = open(".", O_RDONLY | O_DIRECTORY); fcntl(handle, F_NOTIFY, DN_MODIFY | DN_MULTISHOT); while (1) pause(); close(handle); } --- ifmail v.2.15dev5 * Origin: InterCEC, Vinnitsa State Technical University, Ukraine (2:5020/400) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.linux/1668673b564f7.html, оценка из 5, голосов 10
|