#File locked after process interruption

1 messages · Page 1 of 1 (latest)

strong spear
#
const tty_file = try std.fs.openFileAbsolute(path, .{
        .mode = .read_write,
        .lock = .exclusive,
        .lock_nonblocking = true,
});

then I interrupt the process. the next run, I can't use the file – it blocks at open. I understand that it remains locked, or?.. what do I do so that when I run the process again, I can access the file normally?

turbid beacon
#

depending on what operating system you are on (probably linux), file locks can last up to like 10 seconds i think?

#

you need to close the file

#

tty_file.close()

strong spear
turbid beacon
#

you dont

strong spear
#

I must wait 10 seconds?

turbid beacon
#

if its opened and never closed, yes

strong spear
#

well this sucks

turbid beacon
#

im not sure its exactly 10 seconds, but i know they exist after the process ends for a bit

#

just make sure it doesnt interupt?

strong spear
#

I interrupt it myself

#

I'm connecting to the device and when I've tested something, I interrupt it

#

to go back to the code

#

and then rerun. but in this case, I have to reconnect the device as well, which is a bit frustrating

turbid beacon
#

dont interrupt it then. make a system for exiting smoothly

strong spear
#

ok, good idea

#

lol 😄

#

thanks

#

I'll do that

turbid beacon
#

you could wait for a key press for example

strong spear
#

yep

#

that's exactly what I'll do, ty