Skip to content

Instantly share code, notes, and snippets.

@cowens
Created April 15, 2015 17:15
Show Gist options
  • Save cowens/e4f5c67c57b1590a38aa to your computer and use it in GitHub Desktop.
Save cowens/e4f5c67c57b1590a38aa to your computer and use it in GitHub Desktop.
Example of running out of room with print
mkdir ram
sudo mount -t tmpfs -osize=4k tmpfs ram
perl -le 'open $f, ">", "ram/f"; $i = 0; while (print $f "x") { $i++ }; print "ran out of room after $i bytes"'
@ratsbane
Copy link

That's a good point. I should have specified printing to STDOUT. Even then there are things that could go wrong... someone could close STDOUT or select STDOUT to a file or something, but still, I think the clutter of testing every single print statement is a worse problem, in most cases, than an uncaught problem. Even if you catch the problem, what are you going to do about it? Write something to a logfile? If the disk is full you're still stuck.

@ratsbane
Copy link

Interestingly, on linux that stopped at 4096 but on OS X it didn't!

mb:ram doug$ ls -lah
total 2142480
drwxr-xr-x 3 doug staff 102B Apr 15 18:57 .
drwxr-xr-x+ 238 doug staff 7.9K Apr 15 18:57 ..
-rw-r--r-- 1 doug staff 1.0G Apr 15 18:58 f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment