On Wed, Jul 16, 2008 at 9:44 AM, Knowledge Seeker <[EMAIL PROTECTED]> wrote:
> Problem statement > ------------------- > Creating a directory watch thread. Process A writes a text file in a > directory. Process B has to keep watching the directory, whenever a file > is written on it. Process B reads the files and dumps the output on the > screen, and deletes the file. > > Preconditions > ------------- > Process A is unaware of Process B and vice-versa. > > Target Platform > ---------------- > C / C++ on Red Hat Linux > > > I am aware of Pthreads (and have written simple programs using it), but > don't know how to get the details of the directory (linux api), so that > I can look at the data structure and know that a file has been copied in > the directory. So that I can keep a watch thread (a pthread > implementation) over it, and as soon as a file is copied the directory > state change is reflected to me. Take a look at the fstat() system call. Your thread will need to poll to see if the data in the struct returned by fstat() changes. -- Brett ------------------------------------------------------------ "In the rhythm of music a secret is hidden; If I were to divulge it, it would overturn the world." -- Jelaleddin Rumi
