Giter Site home page Giter Site logo

read_write_file's Introduction

read_write_file

Different ways to watch a file for modification (and print its content)

Each ways is implemented as a commit. The descriptions of all commits are listed below. The code is only for learning, and is released under GPL v 3.

Following ways to detect a change in file have been implemented:

  1. Check if the file has been changed in last 5 seconds. If not, it is probably not being written anymore, so quit.
  2. Use inotify socket to read (blocking). Quit on detecting IN_CLOSE event or IN_OPEN event, the idea being that the monitor (read_file) should be openened while the file is being modified.
  3. Converted inotify to a object-oriented design, including an iterator.
  4. Use inotify class in multithreaded environment - a different thread to monitor changes, while the main thread waits for its signal to read the file.
  5. Move inotify to main thread and reading of file to different thread
  6. Use IN_NONBLOCK inotify socket. Main thread calls non-blocking read() every second, and if a change is detected, tells another thread to read rest of the file.
  7. Use epoll to know when to call read, instead of relying on read to fail.

read_write_file's People

Contributors

anupamsr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.