Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!appserv!slovax.Eng.Sun.COM!lm From: lm@slovax.Eng.Sun.COM (Larry McVoy) Newsgroups: comp.lang.perl Subject: perl 4.0beta bug in sysread/syswrite? Message-ID: <536@appserv.Eng.Sun.COM> Date: 6 Apr 91 03:45:43 GMT Sender: news@appserv.Eng.Sun.COM Reply-To: lm@sun.UUCP (Larry McVoy) Organization: Sun Microsystems, Mountain View Lines: 36 I ran into a weird bug, I think. I narrowed it down to sysread and/or syswrite. I can't read what I wrote: #!/bin/perl4.000 # open a temp file, write some lines. open(F, ">/tmp/test") || die "create"; $foo = "perl is the greatest!\n"; for $i (0..3) { syswrite(F, $foo, length($foo), $i * length($foo)) || die "write"; } close(F); # reopen a temp file, make sure the lines are the same. open(F, "/tmp/test") || die "create"; for $i (0..3) { sysread(F, $buf, length($foo), $i * length($foo)) || die "read"; if ($buf ne $foo) { print "buf $i is wrong: \"$buf\"\n"; } } close(F); The trace output looks like so: write (3, "perl is the greatest!\n", 22) = 22 write (3, "".., 22) = 22 write (3, "".., 22) = 22 write (3, "".., 22) = 22 read (3, "perl is the greatest!\n", 22) = 22 read (3, "".., 22) = 22 read (3, "".., 22) = 22 read (3, "".., 22) = 22 --- Larry McVoy, Sun Microsystems (415) 336-7627 ...!sun!lm or lm@sun.com