lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Turns out that this is roughly equivalent to calling fsync() on fd:

os.execute("sync "..filename);

So i went with that. But the argument is not properly escaped, which is fine in my case, since filename is hardcoded.

On the other hand it would be better if there was some way to pass individual arguments in array without using shell to parse the commandline.
Eg.: something like this:

os.execute({"sync", "filename"});

lua can detect that table was passed rather than string. and bypass the shell in that case. That would prevent need to have shell-specific (platform-specific) escaping in lua...




Dne 2022-09-20 08:40, bil til napsal:
The nasty thing here seems to be, that this is different for any
operating system.

Usually it would be nice to implement such functionality into flush I
think, but if you have to write different code for any operating
system, then this gets a bit much for Lua?

(fsync e. g. will not be available in MS-Win, in fact I am not sure at
all how you can accomplish this in MS Win software).

(but you could also say, that it would be job of your Linux compiler
to organize such things, so that flush really works "sure" and not
possibly only "virtual").

Am Mo., 19. Sept. 2022 um 18:40 Uhr schrieb Tomas Mudrunka <mudrunka@spoje.net>:

Note that fflush() flushes only the user-space buffers provided
by the C library. To ensure that the data is physically stored on disk the kernel buffers must be flushed too, for example, with
        sync(2) or fsync(2).

--
S pozdravem
Best regards
     Tomáš Mudruňka - SPOJE.NET s.r.o.