Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In Ext 3/4 filesystem, if I have a log file open and being appended to, if another process tries to read it (e.g. with cat), what happens?

  1. Can the reading process read part of / an incomplete write?
  2. Is reading-during-writing safe and won't disrupt the writing process? Or is there a chance the logs can be corrupted by doing this?

Where should one read more?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

1. Can the reading process read part of / an incomplete write?
The reading process will only be able to read the data that has been written, but to answer the question, yes it could read part of the data if the write has not yet completed.

2. Is reading-during-writing safe and won't disrupt the writing process? Or is there a chance the logs can be corrupted by doing this?
Reading during writing, although not entirely safe, should not disrupt the writing process. Neither will it necessarily corrupt the logs, but any data that is does manage to read will likely be incomplete.

Ultimately I wouldn't recommend it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.