Just to add and clarify; operating systems have their own internal write buffers. When you call fflush() you are saying "immediately flush this data from my program buffers to the operating system".
When you call fsync() you are saying "immediately flush this data from my program buffers to the operating system *and tell the operating system to immediately flush its buffer to disk too*", so when this function returns success status you can be as reliably sure as possible that data has been physically persisted. fflush does not provide this assurance. On Mon, 1 Jun 2020, 18:52 David Gebler, <davidgeb...@gmail.com> wrote: > No, fflush will flush the PHP application buffers out to the operating > system, it does in contrast to fsync not provide a guarantee the operating > system will immediately persist to the underlying storage device. > > On Mon, 1 Jun 2020, 18:49 Dennis Birkholz, <p...@dennis.birkholz.biz> > wrote: > >> Hello David, >> >> isn't fflush exactly this: >> https://www.php.net/manual/en/function.fflush.php >> >> Greets >> Dennis >> >> Am 01.06.20 um 18:56 schrieb David Gebler: >> > Exactly as the subject says, I would like to propose an RFC for adding >> an >> > fsync() function for file resources, which would in essence be a thin >> > wrapper around C's fsync on UNIX systems and _commit on Windows. >> > >> > It seems to me an odd oversight that this has never been implemented in >> PHP >> > and means PHP has no way to perform durable file write operations, >> making >> > it inherently unsuitable for any systems requiring more intensive I/O, >> > mission critical logs, auditing, etc. >> > >> > I am not really a C programmer and I have been able to implement a >> simple >> > working prototype of this as a compiled extension in merely a few >> hours, so >> > I'm sure it wouldn't be difficult to bring in to the language core where >> > the functionality really belongs. >> > >> > Every other major programming language otherwise comparable to PHP in >> > features supports a way of providing durability. >> > >> > Thanks. >> > >> >>