barvin has asked for the wisdom of the Perl Monks concerning the following question:

I'm doing a piped open to less or more from perl on sensitive data like this:
open (my $PAGER, "| $pager") or die "Can't fork a process for $pager: $!"; print $PAGER $text; close $PAGER

Does anyone know if any temporary files are created by less or more (or perl) in this process? The file would never be more than maybe 50KB.

I realize that the data is plain text during viewing and I can live with that, however I would want to shred anything left on the filesystem, I'm just not sure if this ever exists on the filesystem.

The less man pages, website and Google haven't answered this for me.

Thanks,

Barry

Replies are listed 'Best First'.
Re: Temp file on piped open to less
by BrowserUk (Patriarch) on Mar 25, 2010 at 21:21 UTC

    Unless you're running under DOS or C/PM, (is that even possible these days with Perl?), pipes do not touch the filesystem. They are buffered through kernel memory space.

    There is the vague possibility that if your system went into swapping, and then crashed, that some small parts of the file (probably 4k), might turn up in a scan of the systems swap file somewhere.

    If you use less, which allows the user to back up through the file, (as opposed to more which on my system doesn't), then there is the possibility that the system could be forced into swapping and then crashed, and the whole file picked out from the system swap file. Though it would probably be in 4k chunks mixed up amongst loads of other stuff.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Temp file on piped open to less
by zwon (Abbot) on Mar 25, 2010 at 21:15 UTC

    You can use lsof to see if less uses any temporary files.

Re: Temp file on piped open to less
by ikegami (Patriarch) on Mar 25, 2010 at 21:18 UTC

    It doesn't involve any temp files on the Perl side. I can't speak for any version of more and less, much less all of them.

    Note that nothing prevents to the OS from swapping memory pages to disk.