Vim Backup-Copy

While writing a custom version of the tail -f command in C, I stumbled upon an interesting behavior in the Vim/Neovim text editors. The purpose of the program is to continuously print any new data appended to the end of a file—just like tail -f, which is commonly used for watching log files. In my implementation, I have something like this: const char *filename = argv[1]; int fd = open(filename, O_RDONLY); if (fd == -1) { perror("open"); return 1; } The open() function, provided by #include <fcntl.h>, returns a file descriptor—a small, nonnegative integer that acts as an index into the process’s table of open file descriptors. ...

June 12, 2025 · 4 min · Deni Andrian Prayoga