Do files disappear from tmpfs when creating process dies?

453 Views Asked by At

I had a discussion with a colleague about tmpfs: we couldn't agree whether tmpfs files survive the death of the process that created them or not. I argued for yes, but wasn't sure. I know that tmpfs is 'just another file system' but it being memory-only, I wasn't sure about the guarantees. Could someone shed some light on the issue?

2

There are 2 best solutions below

0
On

It just exists in memory. Switch the computer off and it is gone.

But the files to tmpfs is not linked to a particular process.

1
On

Files don't disappear from tmpfs until they are removed or until it is unmounted.

If you want your temporary files to disappear when your process dies, the idiom is to unlink them straight after opening them.