My application basically does a

IPC::Run::run([$someProg,...],'>output.txt');
It does not have any knowledge about what program $someProg is (i.e. the programs to be executed here are not written by me). The app is supposed to run unattended. It is no problem if $someProg takes arbitrarily long to execute, but the following is: If the program happens to loop forever, AND inside the loop writes something to stdout, it simply fills up the disk.

It is OK to limit the size of the output file. For instance, under Unix I would do a ulimit -f before invoking my Perl program, but we are on Windows.

Is there a way to limit the size of a file created, so that Windows would abort a process if it creates a file larger than the limit? Otherwise, is there another possibility to inhibit large files to be created?

I already had the idea to use a pipe,

.... '|perl guarded_tee.pl output.txt'
where guarded_tee.pl would work like a usual 'tee', but would close the pipe after it received more than a certain number of bytes. But aside from that not being a very elegant solution, I don't have enough knowledge about the internals of the Windows piping system, and of the hidden traps which might be lurking. So maybe someone could either point out a different solution, or verify that my 'tee' solution should work without risks in every circumstance.

-- 
Ronald Fischer <ynnor@mm.st>

In reply to Windows-specific: Limiting output of created files by rovf

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.