Tested just now on aix61 and it worked for me. Saved the following program as f.pl:

# From /etc/security/limits: # Sizes are in multiples of 512 byte blocks # fsize - soft file size in blocks # To test this program, I set block size via: # ulimit -f 900 use strict; use warnings; $| = 1; my $bsize = 512; my $ulimit = `ulimit -f`; chomp $ulimit; print "ulimit=$ulimit blocks (block size=$bsize)\n"; my $fname = 'f.tmp'; open my $fh, '>', $fname or die "error: open '$fname': $!"; my $niter = 1000; my $size = 0; my $block = 'a' x $bsize; for my $i (0..$niter) { $size += $bsize; print "$i: $size bytes written\n" if $i % 100 == 0; print $fh $block or die "$i: error in print: $!"; } close $fh or die "error: close: $!";
After issuing the command:
ulimit -f 900
running the above program f.pl produced the following output:
% perl f.pl ulimit=900 blocks (block size=512) 0: 512 bytes written 100: 51712 bytes written 200: 102912 bytes written 300: 154112 bytes written 400: 205312 bytes written 500: 256512 bytes written 600: 307712 bytes written 700: 358912 bytes written 800: 410112 bytes written 900: 461312 bytes written 904: error in print: A file cannot be larger than the value set by uli +mit. at f.pl line 22.

Update: The reason for the program stopping at 904, rather than 900, is user-space buffering by stdio. To verify that it stops at 900 with user-space buffering switched off, I adjusted the above program by adding a call to autoflush right after the output file is opened. Running this adjusted program:

use strict; use warnings; use IO::Handle; # <-- Added this line for autoflush $| = 1; my $bsize = 512; my $ulimit = `ulimit -f`; chomp $ulimit; print "ulimit=$ulimit blocks (block size=$bsize)\n"; my $fname = 'f.tmp'; open my $fh, '>', $fname or die "error: open '$fname': $!"; $fh->autoflush(); # <-- Added this line to make print autoflush my $niter = 1000; my $size = 0; my $block = 'a' x $bsize; for my $i (0..$niter) { print "$i: $size bytes written\n" if $i % 100 == 0; print $fh $block or die "$i: error in print: $!"; $size += $bsize; # <-- Moved this line to after successful print } close $fh or die "error: close: $!";
produced:
ulimit=900 blocks (block size=512) 0: 0 bytes written 100: 51200 bytes written 200: 102400 bytes written 300: 153600 bytes written 400: 204800 bytes written 500: 256000 bytes written 600: 307200 bytes written 700: 358400 bytes written 800: 409600 bytes written 900: 460800 bytes written 900: error in print: A file cannot be larger than the value set by uli +mit. at f.pl line 23.

Note further that the above was run with the korn shell (ksh). The ulimit command is a shell builtin and the block size, on aix at least, seems to be 512 bytes for ksh and 1024 bytes for bash, as shown below:

% type ulimit ulimit is a shell builtin. % ulimit -f 900 % ulimit -f 900 % ksh -c 'ulimit -f' 900 % bash -c 'ulimit -f' 450


In reply to Re: Ulimit being reached by eyepopslikeamosquito
in thread Ulimit being reached by viffer

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.