pipetemporary-filestmpfs

Pipe VS Temporary File on RAM


This is the return of a classic question : for transferring datas between two process, should we use "pipe" or "temporary file".

It was debated here, for reference : Pipe vs. Temporary File

Now, considering only UNIX system, that can use tmpfs or ramfs (RAM based filesystem), we can write temp files really fast.

In my specific case, data is 100Ko PNG image file.

What option would you prefer ?


Solution

  • Even when the performance difference isn't noticeable, temp files still have disadvantages: you have to pick a name that won't collide with any other process's temp files (possibly including other processes of different users, who may be maliciously trying to collide with you). And you have to make sure the file gets removed, even if your process ends abnormally.

    Pipes are awesome. No reason not to use them.