I was playing about with buffering and discovered this:
If I pipe a writer, which doesn't newline terminate, into a reader on linux,
most often the box freezes as the swap
gets sucked up. (observe with top)
I.e. power button reset job.
On my Soalris box at work (sparc) and at home (Intel)
the pipeline gets kicked off, no damage done.
i tried in C also on solaris, using printf with gets
and the buffer flushes occasionally even without the newline.
So maybe there is a perl feature that allows you to fill up buffers and a linux bug which allows a process to freeze the system.
./buffer_write.pl -loop |  buffer_read.pl
Here is my code:
buffer_write.pl
#!/bin/perl -s
$main::size ||= 10_000;
$count;
sub do_write {
$buf = chr int(rand(25)+65);
$message = $buf x $size;
$message .= "\n" if $line;;
print "$message";
$count += length $message;
warn "$count bytes\n";
}
while ($loop || <>) {
do_write;
}
buffer_read.pl
#!/bin/perl -n
print length($_), "\n";
print;
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.