2 ms·
> I wonder what happens when open() gets a mode flag with both "a" and "t" set? Nothing I expect. O_TRUNC and O_APPEND are not incompatible, O_APPEND is just r
by masklinn 4y ago
> I wonder what happens when open() gets a mode flag with both "a" and "t" set?
Nothing I expect. O_TRUNC and O_APPEND are not incompatible, O_APPEND is just redundant (because by definition if you truncate the file you're writing at its end).
macOS certainly doesn't seem to care when I do it.
- cesarb 4y ago> O_APPEND is just redundant (because by definition if you truncate the file you're writing at its end). No, O_APPEND is not redundant with O_TRUNC. When you use O_APPEND, you also have the extra behavior that every write goes to the end of the file, instead of the current position; this is important when more than one process is writing to the same file.