lua-users home
lua-l archive

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


fsync is not avaliable in io.*

try to use flush()


local f = io.open('file.txt', 'w')
f:write('hello')
f:flush()
f:close()
f = nil








---- Em Seg, 19 set 2022 12:40:15 -0300 Tomas Mudrunka <mudrunka@spoje.net> escreveu ---

Hello,
i have Lua script on Linux that opens file handle using io.open(),
writes to it using :write() and closes it using :close().

I really need way to call fsync() on that file descriptor.
https://man7.org/linux/man-pages/man2/fsync.2.html

Either as an argument, eg.: file:write(true) file:close(true)
or as separate call file:sync(). Is there way to do that?
If not, can you see this being added in the future?

I know as a workaround i can call os.execute("sync");
But that triggers system wide sync of all files and filesystems, which
is not really desirable.

--
S pozdravem
Best regards
Tomáš Mudruňka