That is fairly easy to do under ubuntu. Firstly create a tmpfs partition of a suitable size, and define a mount point.

In your /etc/fstab:

none /binary_exec tmpfs size=2G 0 0

Or on the command line (as root)

mount none /binary_exec -t tmpfs -o size=2G

The mount point for the tmpfs partition must be created as a directory first. It need not be in the root of your file-system.

You can be quite generous with the size of the tmpfs volume, as it is only the upper limit for the file-system, so you won't consume 2G of RAM just by creating the file-system, only the total size of the files you write there, and in any case file data in tmpfs will get swapped out if the fs is large enough to cause memory pressure.

Once you have created the temporary partition, you can write your executable binary there from your perl scalar in the normal way. It should be very quick as you are just copying bytes from one part of ram to another. From there it is trivial to run the executable. You can also delete files just as quickly.


In reply to Re^3: Spawning processes from scalars by chrestomanci
in thread Spawning processes from scalars by fluffyvoidwarrior

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.