Chirantan
Chirantan

Reputation: 15634

Is it okay to unlink files without closing them in ruby?

Is it safe to unlink a file in ruby in Linux without closing it first? Does it matter?

Upvotes: 1

Views: 1798

Answers (1)

user703016
user703016

Reputation: 37945

On linux this is safe and is often used to create undiscoverable temporary files.

You can read and write from and to the file as long as you have it opened, whether it was deleted or not is irrelevant. The file will truly disappear when you close it AND delete it, no matter the order.

Upvotes: 4

Related Questions