Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: print return code bug... Message-ID: <7996@jpl-devvax.JPL.NASA.GOV> Date: 6 May 90 02:36:27 GMT References: <1990May4.202029.9341@eci386.uucp> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 39 In article <1990May4.202029.9341@eci386.uucp> clewis@eci386 (Chris Lewis) writes: : Unless I've missed something, this is supposed to fill up your : file system and then stop, but it ain't stopping: : : > open(handle, ">/usr5/test"); : > printf $!; : > $v = "1111111111111111111111111111111111111111111111111111111111111111111"; : > $v = "$v$v$v$v$v$v$v$v$v$v$v"; : > # Speedups : > $v = substr($v, 0, 511); : > $! = ""; : > while(1) { : > (printf handle ($v)) || die "BOOM! $! $@"; : > } : : Be careful about running this ;-) if you want to test it, you might want : to try something different - the point is, printf doesn't appear to be : returning 0 on a write error (as the manual appears to imply it should - : it does say print is supposed to and then defines printf in terms of : print).. Hmm, apparently fwrite() isn't checking the error status if it has to do a flush. Nothing much I can do about that. You can check it yourself though if you say select(handle); $| = 1; This causes an explicit fflush(), which perl checks the error status of. On the other hand, perhaps I can force errno to a 0 before the fwrite() and then see if it gets set. Hang on, let me try that... Ok, that seems to work ok. I just hope nobody's fwrite() sets errno just for the fun of it. Someday I'm just gonna bypass fwrite() altogether... Larry