AIX doesn't have a 'top' command. Well, I'd like to create an emulation for it using perl and "ps guw" piped to sort. I have the following so far:
... my $pid = fork(); # spawn child if ( $pid ) { # parent while ( wait != -1 ) { while (<>) { print "Got $_ on STDIN\n"; } } } else { # child while ( 1 ) { print $header; print `ps guw | sort -n -r -k $sort_option | head -$num_lines`; print "\nSort: $sort_option : Lines: $num_lines : Sleep: $sleep_ti +me\n"; sleep $sleep_time; print `clear`; } }
Pretty rudimentary, but what I would like to do is have the parent process listen for STDIN, like top does, and send a SIGHUP to the child to reset it's sort options, lines or whatnot. The while (<>) { doesn't seem to be working like I'd hoped. Any ideas on this one?

In reply to Emulating UNIX 'top' on AIX by Transient

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.