'On Linux, how is the conflict handled that a file is being written by one process while another process "tail -f" keeps reading it?

On Linux, we can launch a shell script, which keeps writing lines into a file, and at the same time, another "tail -f" process keeps reading the latest tail of the file.

I know that when two processes are accessing the same file, some file locking mechanisms should be utilized to avoid conflict and undefined behaviour, just as in-memory mutexes. Does that mean all the Linux shell commands which involve file reading/writing already have that under their belts? Or do I misunderstand something and this kind of locking is not a necessitate?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source