Your program (and your complete 'overkill' solution) led me to finding the solution -- as I took you overkill solution and stripped out the C and converted it to perl...and that finally hilighted what was wrong with my original program.
the problem is nothing to do with a "problem with STDOUT" ---
it's the **result** word ".
Changing the line:
my $winsize=0;
to
my $winsize=' ' x 8;
Solves the problem. It works. ( " ' 'x 8 " =~= your " \0 x 8 " )
At this point, the problem is clear. ioctl doesnt' allocate space for the return value -- it expects the space to already be there. The 'Bad address' error message that comes back is a reference to my having given ioctl a bad-address for the result buffer.
Once I give it the needed space (for 4 'shorts') -- it's happy!
ARGGGG!!!! I've been programming in Perl for too long and forgotten my "C" basics...
So *thank you* 'tchrist', for writing your example with *correct code*, that allowed me to find the difference between working and not, and also, thank-you for answering the question I was asking rather than trying to get me to use 'something else'.
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.