Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: write to /dev/full does not fail

by choroba (Cardinal)
on May 23, 2014 at 07:48 UTC ( [id://1087174]=note: print w/replies, xml ) Need Help??


in reply to Re^2: write to /dev/full does not fail
in thread write to /dev/full does not fail

Interestingly, if you print a lot, print itself will die:
perl -wE 'open my $F, ">", "/dev/full" or die "open:$!"; for (1..10000) { print $F "line\n" or die "print:$!"; }; close $F or die "close:$!"; '
print:No space left on device at -e line 3.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^4: write to /dev/full does not fail
by Discipulus (Canon) on May 23, 2014 at 07:57 UTC
    no, it seems to me it always, only dies on close:
    #this not dies perl -e 'open FH, ">", "/dev/full" or die $!; for (1..100) {print FH " +line\n" or die $!;} ' #this too not dies perl -e '$|++;open FH, ">", "/dev/full" or die $!; for (1..100) {prin +t FH "line\n" or die $!;} ' #only this dies, on close perl -e 'open FH, ">", "/dev/full" or die $!; for (1..100) {print FH +"line\n" or die $!;}; close FH or die $!' No space left on device at -e line 1.
    UPDATE: as suggested by choroba 100 are few (magic number seems to be 820):
    # this still does not die perl -e '$|++;open FH, ">", "/dev/full" or die $!; for (1..819) {print + FH "line\n" or die $!;} ' #but this dies! perl -e '$|++;open FH, ">", "/dev/full" or die $!; for (1..1000) {pri +nt FH "line\n" or die $!;} ' No space left on device at -e line 1.
    820 is to much? Perl becomes bored after 820 errors (not spotted)? is very patient: i'm hurted by second error.. ;=)
    # perl -e 'print "$_\n" for 1..10000' | perl -ne '$num = <STDIN>;print + "$num:";open FH, ">", "/dev/full" or die $!; for (1..$num) {print FH + "line\n" or die $!;};close FH;' .. :816 :818 :820 No space left on device at -e line 1, <STDIN> line 410.
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      "line\n" is 5 bytes.

      820 * 5 = 4100.

      Buffer size for linux is 4096, so the write hits the actual device on your 820th iteration.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1087174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2024-04-23 13:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found