Implement “tail -f” in C++

后端 未结 6 599
灰色年华
灰色年华 2020-12-10 03:47

I want to create a small code in C++ with the same functionality as \"tail-f\": watch for new lines in a text file and show them in the standard output.

The idea is

6条回答
  •  星月不相逢
    2020-12-10 03:52

    Have a look at inotify on Linux or kqueue on Mac OS.

    Inotify is Linux kernel subsystem that allows you to subscribe for events on files and it will report to your application when the even happened on your file.

提交回复
热议问题